diff options
author | Baptiste Coudurier <baptiste.coudurier@gmail.com> | 2006-11-07 13:45:08 +0000 |
---|---|---|
committer | Baptiste Coudurier <baptiste.coudurier@gmail.com> | 2006-11-07 13:45:08 +0000 |
commit | 80d617f5b47a0c92ec31b59cfd090037c230742f (patch) | |
tree | 4da19fdc076e21035a51cd5508a3f46190bc9616 /libavcodec/mpeg12.c | |
parent | d9d2f88def1b2ad2f3dc5737c27463ffda6c8884 (diff) | |
download | ffmpeg-80d617f5b47a0c92ec31b59cfd090037c230742f.tar.gz |
add option to set mpeg1/2 gop timecode start, and drop frame flag timecode flag
Originally committed as revision 6933 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavcodec/mpeg12.c')
-rw-r--r-- | libavcodec/mpeg12.c | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/libavcodec/mpeg12.c b/libavcodec/mpeg12.c index ea4108fe16..a7d8dc1dcd 100644 --- a/libavcodec/mpeg12.c +++ b/libavcodec/mpeg12.c @@ -240,6 +240,11 @@ static int encode_init(AVCodecContext *avctx) if(avctx->level == FF_LEVEL_UNKNOWN) avctx->level = s->chroma_format == CHROMA_420 ? 8 : 5; + if((avctx->flags2 & CODEC_FLAG2_DROP_FRAME_TIMECODE) && s->frame_rate_index != 4){ + av_log(avctx, AV_LOG_ERROR, "Drop frame time code only allowed with 1001/30000 fps\n"); + return -1; + } + return 0; } @@ -346,13 +351,20 @@ static void mpeg1_encode_sequence_header(MpegEncContext *s) } put_header(s, GOP_START_CODE); - put_bits(&s->pb, 1, 0); /* do drop frame */ + put_bits(&s->pb, 1, !!(s->avctx->flags & CODEC_FLAG2_DROP_FRAME_TIMECODE)); /* drop frame flag */ /* time code : we must convert from the real frame rate to a fake mpeg frame rate in case of low frame rate */ fps = (framerate.num + framerate.den/2)/ framerate.den; - time_code = s->current_picture_ptr->coded_picture_number; - - s->gop_picture_number = time_code; + time_code = s->current_picture_ptr->coded_picture_number + s->avctx->timecode_frame_start; + + s->gop_picture_number = s->current_picture_ptr->coded_picture_number; + if (s->avctx->flags2 & CODEC_FLAG2_DROP_FRAME_TIMECODE) { + /* only works for NTSC 29.97 */ + int d = time_code / 17982; + int m = time_code % 17982; + //if (m < 2) m += 2; /* not needed since -2,-1 / 2 in C returns 0 */ + time_code += 18 * d + 2 * ((m - 2) / 1798); + } put_bits(&s->pb, 5, (uint32_t)((time_code / (fps * 3600)) % 24)); put_bits(&s->pb, 6, (uint32_t)((time_code / (fps * 60)) % 60)); put_bits(&s->pb, 1, 1); |