diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h index c9165ad25e..1381a3e018 100644 --- a/libavcodec/avcodec.h +++ b/libavcodec/avcodec.h @@ -2710,9 +2710,9 @@ typedef struct AVCodecContext { #endif /** - * GOP timecode frame start number, in non drop frame format - * - encoding: Set by user. - * - decoding: unused + * GOP timecode frame start number + * - encoding: Set by user, in non drop frame format + * - decoding: Set by libavcodec (timecode in the 25 bits format, -1 if unset) */ int64_t timecode_frame_start; diff --git a/libavcodec/mpeg12.c b/libavcodec/mpeg12.c index 53857482ea..fde4e0217e 100644 --- a/libavcodec/mpeg12.c +++ b/libavcodec/mpeg12.c @@ -2141,20 +2141,12 @@ static void mpeg_decode_gop(AVCodecContext *avctx, { Mpeg1Context *s1 = avctx->priv_data; MpegEncContext *s = &s1->mpeg_enc_ctx; - - int drop_frame_flag; - int time_code_hours, time_code_minutes; - int time_code_seconds, time_code_pictures; int broken_link; + int64_t tc; init_get_bits(&s->gb, buf, buf_size*8); - drop_frame_flag = get_bits(&s->gb, 1); - time_code_hours = get_bits(&s->gb, 5); - time_code_minutes = get_bits(&s->gb, 6); - skip_bits1(&s->gb); // marker bit - time_code_seconds = get_bits(&s->gb, 6); - time_code_pictures = get_bits(&s->gb, 6); + tc = avctx->timecode_frame_start = get_bits(&s->gb, 25); s->closed_gop = get_bits1(&s->gb); /*broken_link indicate that after editing the @@ -2162,11 +2154,17 @@ static void mpeg_decode_gop(AVCodecContext *avctx, are missing (open gop)*/ broken_link = get_bits1(&s->gb); - if (s->avctx->debug & FF_DEBUG_PICT_INFO) + if (s->avctx->debug & FF_DEBUG_PICT_INFO) { + int time_code_hours = tc>>19 & 0x1f; + int time_code_minutes = tc>>13 & 0x3f; + int time_code_seconds = tc>>6 & 0x3f; + int drop_frame_flag = tc & 1<<24; + int time_code_pictures = tc & 0x3f; av_log(s->avctx, AV_LOG_DEBUG, "GOP (%02d:%02d:%02d%c%02d) closed_gop=%d broken_link=%d\n", time_code_hours, time_code_minutes, time_code_seconds, drop_frame_flag ? ';' : ':', time_code_pictures, s->closed_gop, broken_link); + } } /** * Find the end of the current frame in the bitstream. diff --git a/libavcodec/mpeg12enc.c b/libavcodec/mpeg12enc.c index 653fb4015c..3cfe733139 100644 --- a/libavcodec/mpeg12enc.c +++ b/libavcodec/mpeg12enc.c @@ -185,6 +185,8 @@ static av_cold int encode_init(AVCodecContext *avctx) if (ff_init_smtpe_timecode(s, &s->tc) < 0) return -1; s->avctx->timecode_frame_start = s->tc.start; + } else { + s->avctx->timecode_frame_start = 0; // default is -1 } return 0; } diff --git a/libavcodec/options.c b/libavcodec/options.c index e8fbb6b2fd..0a82d50612 100644 --- a/libavcodec/options.c +++ b/libavcodec/options.c @@ -578,6 +578,7 @@ int avcodec_get_context_defaults3(AVCodecContext *s, AVCodec *codec){ s->sample_aspect_ratio = (AVRational){0,1}; s->pix_fmt = PIX_FMT_NONE; s->sample_fmt = AV_SAMPLE_FMT_NONE; + s->timecode_frame_start = -1; s->reget_buffer = avcodec_default_reget_buffer; s->reordered_opaque = AV_NOPTS_VALUE; diff --git a/libavcodec/version.h b/libavcodec/version.h index 31145db362..b955116c6a 100644 --- a/libavcodec/version.h +++ b/libavcodec/version.h @@ -21,7 +21,7 @@ #define AVCODEC_VERSION_H #define LIBAVCODEC_VERSION_MAJOR 53 -#define LIBAVCODEC_VERSION_MINOR 38 +#define LIBAVCODEC_VERSION_MINOR 39 #define LIBAVCODEC_VERSION_MICRO 1 #define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \