Recherche avancée

Médias (0)

Mot : - Tags -/diogene

Aucun média correspondant à vos critères n’est disponible sur le site.

Autres articles (53)

  • Le profil des utilisateurs

    12 avril 2011, par

    Chaque utilisateur dispose d’une page de profil lui permettant de modifier ses informations personnelle. Dans le menu de haut de page par défaut, un élément de menu est automatiquement créé à l’initialisation de MediaSPIP, visible uniquement si le visiteur est identifié sur le site.
    L’utilisateur a accès à la modification de profil depuis sa page auteur, un lien dans la navigation "Modifier votre profil" est (...)

  • Configurer la prise en compte des langues

    15 novembre 2010, par

    Accéder à la configuration et ajouter des langues prises en compte
    Afin de configurer la prise en compte de nouvelles langues, il est nécessaire de se rendre dans la partie "Administrer" du site.
    De là, dans le menu de navigation, vous pouvez accéder à une partie "Gestion des langues" permettant d’activer la prise en compte de nouvelles langues.
    Chaque nouvelle langue ajoutée reste désactivable tant qu’aucun objet n’est créé dans cette langue. Dans ce cas, elle devient grisée dans la configuration et (...)

  • XMP PHP

    13 mai 2011, par

    Dixit Wikipedia, XMP signifie :
    Extensible Metadata Platform ou XMP est un format de métadonnées basé sur XML utilisé dans les applications PDF, de photographie et de graphisme. Il a été lancé par Adobe Systems en avril 2001 en étant intégré à la version 5.0 d’Adobe Acrobat.
    Étant basé sur XML, il gère un ensemble de tags dynamiques pour l’utilisation dans le cadre du Web sémantique.
    XMP permet d’enregistrer sous forme d’un document XML des informations relatives à un fichier : titre, auteur, historique (...)

Sur d’autres sites (4560)

  • avcodec/huffyuv : Speed up generating Huffman codes

    1er octobre 2022, par Andreas Rheinhardt
    avcodec/huffyuv : Speed up generating Huffman codes
    

    The codes here have the property that the long codes
    are to the left of the tree (each zero bit child node
    is by definition to the left of its one bit sibling) ;
    they also have the property that among codes of the same length,
    the symbol is ascending from left to right.

    These properties can be used to create the codes from
    the lengths in only two passes over the array of lengths
    (the current code uses one pass for each length, i.e. 32) :
    First one counts how many nodes of each length there are.
    Then one calculates the range of codes of each length
    (possible because the codes are ordered by length in the tree).
    This enables one to calculate the actual codes with only
    one further traversal of the length array.

    Signed-off-by : Andreas Rheinhardt <andreas.rheinhardt@outlook.com>

    • [DH] libavcodec/huffyuv.c
  • Accented characters are not recognized in python [closed]

    10 avril 2023, par CorAnna

    I have a problem in the python script, my script should put subtitles in a video given a srt file, this srt file is written by another script but in its script it replaces the accents and all the particular characters with a black square symbol with a question mark inside it... the problem I think lies in the writing of this file, what follows and that in overwriting the subtitles I do with ffmpeg the sentences that contain an accented word are not written

    &#xA;

    def video_audio_file_writer(video_file):&#xA;&#xA;    videos_folder = "Video"&#xA;    audios_folder = "Audio"&#xA;&#xA;    video_path = f"{videos_folder}\\{video_file}"&#xA;&#xA;    video_name = Path(video_path).stem&#xA;    audio_name = f"{video_name}Audio"&#xA;&#xA;    audio_path = f"{audios_folder}\\{audio_name}.wav"&#xA;&#xA;    video = mp.VideoFileClip(video_path)&#xA;    audio = video.audio.write_audiofile(audio_path)&#xA;&#xA;    return video_path, audio_path, video_name&#xA;&#xA;    def audio_file_transcription(audio_path, lang):&#xA;&#xA;    model = whisper.load_model("base")&#xA;    tran = gt.Translator()&#xA;&#xA;    audio_file = str(audio_path)&#xA;&#xA;    options = dict(beam_size=5, best_of=5)&#xA;    translate = dict(task="translate", **options)&#xA;    result = model.transcribe(audio_file, **translate)   &#xA;&#xA;    return result&#xA;&#xA;def audio_subtitles_transcription(result, video_name):&#xA;&#xA;    subtitle_folder = "Content"&#xA;    subtitle_name = f"{video_name}Subtitle"&#xA;    subtitle_path_form = "srt"&#xA;&#xA;    subtitle_path = f"{subtitle_folder}\\{subtitle_name}.{subtitle_path_form}"&#xA;&#xA;    with open(os.path.join(subtitle_path), "w") as srt:&#xA;        # write_vtt(result["segments"], file=vtt)&#xA;        write_srt(result["segments"], file=srt)&#xA;            &#xA;    return subtitle_path&#xA;&#xA;def video_subtitles(video_path, subtitle_path, video_name):&#xA;&#xA;    video_subtitled_folder = "VideoSubtitles"&#xA;    video_subtitled_name = f"{video_name}Subtitles"&#xA;    video_subtitled_path = f"{video_subtitled_folder}\\{video_subtitled_name}.mp4"&#xA;&#xA;    video_path_b = bytes(video_path, &#x27;utf-8&#x27;)&#xA;    subtitle_path_b = bytes(subtitle_path, &#x27;utf-8&#x27;)&#xA;    video_subtitled_path_b = bytes(video_subtitled_path, &#x27;utf-8&#x27;)&#xA;&#xA;    path_abs_b = os.getcwdb() &#x2B; b"\\"&#xA;&#xA;    path_abs_bd = path_abs_b.decode(&#x27;utf-8&#x27;)&#xA;    video_path_bd= video_path_b.decode(&#x27;utf-8&#x27;)&#xA;    subtitle_path_bd = subtitle_path_b.decode(&#x27;utf-8&#x27;)&#xA;    video_subtitled_path_bd = video_subtitled_path_b.decode(&#x27;utf-8&#x27;)&#xA;&#xA;    video_path_abs = str(path_abs_bd &#x2B; video_path_bd)&#xA;    subtitle_path_abs = str(path_abs_bd &#x2B; subtitle_path_bd).replace("\\", "\\\\").replace(":", "\\:")&#xA;    video_subtitled_path_abs = str(path_abs_bd &#x2B; video_subtitled_path_bd)&#xA;&#xA;    time.sleep(3)&#xA;&#xA;    os.system(f"ffmpeg -i {video_path_abs} -vf subtitles=&#x27;{subtitle_path_abs}&#x27; -y {video_subtitled_path_abs}")&#xA;&#xA;    return video_subtitled_path_abs, video_path_abs, subtitle_path_abs&#xA;&#xA;if __name__ == "__main__":&#xA;&#xA;    video_path, audio_path, video_name = video_audio_file_writer(video_file="ChiIng.mp4")&#xA;    result = audio_file_transcription(audio_path=audio_path, lang="it")&#xA;    subtitle_path = audio_subtitles_transcription(result=result, video_name=video_name)&#xA;    video_subtitled_path_abs, video_path_abs, subtitle_path_abs = video_subtitles(video_path=video_path, subtitle_path=subtitle_path, video_name=video_name)&#xA;    &#xA;    print("Video Subtitled")&#xA;

    &#xA;

    Windows 11&#xA;Python 3.10

    &#xA;

  • Bit-field badness

    30 janvier 2010, par Mans — Compilers, Optimisation

    Consider the following C code which is based on an real-world situation.

    struct bf1_31 
        unsigned a:1 ;
        unsigned b:31 ;
     ;
    

    void func(struct bf1_31 *p, int n, int a)

    int i = 0 ;
    do
    if (p[i].a)
    p[i].b += a ;
    while (++i < n) ;

    How would we best write this in ARM assembler ? This is how I would do it :

    func :
            ldr     r3,  [r0], #4
            tst     r3,  #1
            add     r3,  r3,  r2,  lsl #1
            strne   r3,  [r0, #-4]
            subs    r1,  r1,  #1
            bgt     func
            bx      lr
    

    The add instruction is unconditional to avoid a dependency on the comparison. Unrolling the loop would mask the latency of the ldr instruction as well, but that is outside the scope of this experiment.

    Now compile this code with gcc -march=armv5te -O3 and watch in horror :

    func :
            push    r4
            mov     ip, #0
            mov     r4, r2
    loop :
            ldrb    r3, [r0]
            add     ip, ip, #1
            tst     r3, #1
            ldrne   r3, [r0]
            andne   r2, r3, #1
            addne   r3, r4, r3, lsr #1
            orrne   r2, r2, r3, lsl #1
            strne   r2, [r0]
            cmp     ip, r1
            add     r0, r0, #4
            blt     loop
            pop     r4
            bx      lr
    

    This is nothing short of awful :

    • The same value is loaded from memory twice.
    • A complicated mask/shift/or operation is used where a simple shifted add would suffice.
    • Write-back addressing is not used.
    • The loop control counts up and compares instead of counting down.
    • Useless mov in the prologue ; swapping the roles or r2 and r4 would avoid this.
    • Using lr in place of r4 would allow the return to be done with pop {pc}, saving one instruction (ignoring for the moment that no callee-saved registers are needed at all).

    Even for this trivial function the gcc-generated code is more than twice the optimal size and slower by approximately the same factor.

    The main issue I wanted to illustrate is the poor handling of bit-fields by gcc. When accessing bitfields from memory, gcc issues a separate load for each field even when they are contained in the same aligned memory word. Although each load after the first will most likely hit L1 cache, this is still bad for several reasons :

    • Loads have typically two or three cycles result latency compared to one cycle for data processing instructions. Any bit-field can be extracted from a register with two shifts, and on ARM the second of these can generally be achieved using a shifted second operand to a following instruction. The ARMv6T2 instruction set also adds the SBFX and UBFX instructions for extracting any signed or unsigned bit-field in one cycle.
    • Most CPUs have more data processing units than load/store units. It is thus more likely for an ALU instruction than a load/store to issue without delay on a superscalar processor.
    • Redundant memory accesses can trigger early flushing of store buffers rendering these less efficient.

    No gcc bashing is complete without a comparison with another compiler, so without further ado, here is the ARM RVCT output (armcc --cpu 5te -O3) :

    func :
            mov     r3, #0
            push    r4, lr
    loop :
            ldr     ip, [r0, r3, lsl #2]
            tst     ip, #1
            addne   ip, ip, r2, lsl #1
            strne   ip, [r0, r3, lsl #2]
            add     r3, r3, #1
            cmp     r3, r1
            blt     loop
            pop     r4, pc
    

    This is much better, the core loop using only one instruction more than my version. The loop control is counting up, but at least this register is reused as offset for the memory accesses. More remarkable is the push/pop of two registers that are never used. I had not expected to see this from RVCT.

    Even the best compilers are still no match for a human.