mirror of
https://git.videolan.org/git/ffmpeg.git
synced 2024-08-22 09:15:06 +02:00
mpeg12: raise timecode to codec context.
This commit is contained in:
parent
2cf4bd7751
commit
b1ca5634fd
@ -2710,9 +2710,9 @@ typedef struct AVCodecContext {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* GOP timecode frame start number, in non drop frame format
|
* GOP timecode frame start number
|
||||||
* - encoding: Set by user.
|
* - encoding: Set by user, in non drop frame format
|
||||||
* - decoding: unused
|
* - decoding: Set by libavcodec (timecode in the 25 bits format, -1 if unset)
|
||||||
*/
|
*/
|
||||||
int64_t timecode_frame_start;
|
int64_t timecode_frame_start;
|
||||||
|
|
||||||
|
@ -2141,20 +2141,12 @@ static void mpeg_decode_gop(AVCodecContext *avctx,
|
|||||||
{
|
{
|
||||||
Mpeg1Context *s1 = avctx->priv_data;
|
Mpeg1Context *s1 = avctx->priv_data;
|
||||||
MpegEncContext *s = &s1->mpeg_enc_ctx;
|
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;
|
int broken_link;
|
||||||
|
int64_t tc;
|
||||||
|
|
||||||
init_get_bits(&s->gb, buf, buf_size*8);
|
init_get_bits(&s->gb, buf, buf_size*8);
|
||||||
|
|
||||||
drop_frame_flag = get_bits(&s->gb, 1);
|
tc = avctx->timecode_frame_start = get_bits(&s->gb, 25);
|
||||||
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);
|
|
||||||
|
|
||||||
s->closed_gop = get_bits1(&s->gb);
|
s->closed_gop = get_bits1(&s->gb);
|
||||||
/*broken_link indicate that after editing the
|
/*broken_link indicate that after editing the
|
||||||
@ -2162,12 +2154,18 @@ static void mpeg_decode_gop(AVCodecContext *avctx,
|
|||||||
are missing (open gop)*/
|
are missing (open gop)*/
|
||||||
broken_link = get_bits1(&s->gb);
|
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",
|
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,
|
time_code_hours, time_code_minutes, time_code_seconds,
|
||||||
drop_frame_flag ? ';' : ':',
|
drop_frame_flag ? ';' : ':',
|
||||||
time_code_pictures, s->closed_gop, broken_link);
|
time_code_pictures, s->closed_gop, broken_link);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* Find the end of the current frame in the bitstream.
|
* Find the end of the current frame in the bitstream.
|
||||||
* @return the position of the first byte of the next frame, or -1
|
* @return the position of the first byte of the next frame, or -1
|
||||||
|
@ -185,6 +185,8 @@ static av_cold int encode_init(AVCodecContext *avctx)
|
|||||||
if (ff_init_smtpe_timecode(s, &s->tc) < 0)
|
if (ff_init_smtpe_timecode(s, &s->tc) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
s->avctx->timecode_frame_start = s->tc.start;
|
s->avctx->timecode_frame_start = s->tc.start;
|
||||||
|
} else {
|
||||||
|
s->avctx->timecode_frame_start = 0; // default is -1
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -578,6 +578,7 @@ int avcodec_get_context_defaults3(AVCodecContext *s, AVCodec *codec){
|
|||||||
s->sample_aspect_ratio = (AVRational){0,1};
|
s->sample_aspect_ratio = (AVRational){0,1};
|
||||||
s->pix_fmt = PIX_FMT_NONE;
|
s->pix_fmt = PIX_FMT_NONE;
|
||||||
s->sample_fmt = AV_SAMPLE_FMT_NONE;
|
s->sample_fmt = AV_SAMPLE_FMT_NONE;
|
||||||
|
s->timecode_frame_start = -1;
|
||||||
|
|
||||||
s->reget_buffer = avcodec_default_reget_buffer;
|
s->reget_buffer = avcodec_default_reget_buffer;
|
||||||
s->reordered_opaque = AV_NOPTS_VALUE;
|
s->reordered_opaque = AV_NOPTS_VALUE;
|
||||||
|
@ -21,7 +21,7 @@
|
|||||||
#define AVCODEC_VERSION_H
|
#define AVCODEC_VERSION_H
|
||||||
|
|
||||||
#define LIBAVCODEC_VERSION_MAJOR 53
|
#define LIBAVCODEC_VERSION_MAJOR 53
|
||||||
#define LIBAVCODEC_VERSION_MINOR 38
|
#define LIBAVCODEC_VERSION_MINOR 39
|
||||||
#define LIBAVCODEC_VERSION_MICRO 1
|
#define LIBAVCODEC_VERSION_MICRO 1
|
||||||
|
|
||||||
#define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \
|
#define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \
|
||||||
|
Loading…
Reference in New Issue
Block a user