[FFmpeg-devel] [PATCH] lavf/matroskaenc: Write Block Keyframe correctly

Vignesh Venkatasubramanian vigneshv at google.com
Fri Jun 5 01:30:14 CEST 2015


On Thu, Jun 4, 2015 at 4:25 PM, Michael Niedermayer <michaelni at gmx.at> wrote:
> On Tue, Jun 02, 2015 at 12:31:53PM -0700, Vignesh Venkatasubramanian wrote:
>> Per matroska Block Structure [1], for keyframes 0th bit of the flag
>> should not be set (unlike SimpleBlocks). For Blocks, keyframes is
>> inferred by the absence of ReferenceBlock element (as done by
>> matroskadec). This CL writes the flag correctly and inserts the
>> ReferenceBlock element for non-keyframes. The timestamp inserted is
>> that of the immediately preceding frame (which is true for VP8 and VP9
>> - the only 2 codecs using the matroska block element as of now). It
>> also considers all non-video frames (audio, subtitles, metadata) to
>> be keyframes.
>>
>> [1] http://www.matroska.org/technical/specs/index.html#block_structure
>>
>> Signed-off-by: Vignesh Venkatasubramanian <vigneshv at google.com>
>> ---
>>  libavformat/matroskaenc.c | 30 +++++++++++++++++++++++-------
>>  1 file changed, 23 insertions(+), 7 deletions(-)
>>
>> diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c
>> index aa9d119..98b6500 100644
>> --- a/libavformat/matroskaenc.c
>> +++ b/libavformat/matroskaenc.c
>> @@ -95,6 +95,10 @@ typedef struct mkv_track {
>>  #define MODE_MATROSKAv2 0x01
>>  #define MODE_WEBM       0x02
>>
>> +/** Maximum number of tracks allowed in a Matroska file (with track numbers in
>> + * range 1 to 126 (inclusive) */
>> +#define MAX_TRACKS 126
>> +
>>  typedef struct MatroskaMuxContext {
>>      const AVClass  *class;
>>      int             mode;
>> @@ -125,6 +129,8 @@ typedef struct MatroskaMuxContext {
>>      uint32_t chapter_id_offset;
>>      int wrote_chapters;
>>
>> +    int64_t last_track_timestamp[MAX_TRACKS];
>> +
>>      int allow_raw_vfw;
>>  } MatroskaMuxContext;
>>
>
>> @@ -1354,6 +1360,7 @@ static int mkv_write_header(AVFormatContext *s)
>>              version = 4;
>>      }
>>
>> +    memset(mkv->last_track_timestamp, 0, MAX_TRACKS);
>
> isnt the memset redundant as the context gets zeroed on allocation ?
>

thanks for pointing this out. done.

> [...]
> --
> Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
>
> I am the wisest man alive, for I know one thing, and that is that I know
> nothing. -- Socrates
>
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel at ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>



-- 
Vignesh


More information about the ffmpeg-devel mailing list