[FFmpeg-devel] [PATCH] lavf/matroskaenc: Write Block Keyframe correctly
Vignesh Venkatasubramanian
vigneshv at google.com
Tue Jun 2 21:32:14 CEST 2015
On Mon, Jun 1, 2015 at 5:35 PM, James Almer <jamrial at gmail.com> wrote:
> On 01/06/15 9:07 PM, 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 | 33 ++++++++++++++++++++++++++-------
>> 1 file changed, 26 insertions(+), 7 deletions(-)
>>
>> diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c
>> index aa9d119..70d4375 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,10 @@ static int mkv_write_header(AVFormatContext *s)
>> version = 4;
>> }
>>
>> + for (i = 0; i < MAX_TRACKS; i++) {
>> + mkv->last_track_timestamp[i] = 0;
>> + }
>
> memset, or make last_track_timestamp a pointer and use av_mallocz.
done. used memset.
>
> _______________________________________________
> 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