mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2025-01-24 13:56:33 +02:00
mpeg12enc: use new public timecode API.
This commit is contained in:
parent
f65600d519
commit
d8804905eb
@ -33,10 +33,10 @@
|
|||||||
#include "mpeg12.h"
|
#include "mpeg12.h"
|
||||||
#include "mpeg12data.h"
|
#include "mpeg12data.h"
|
||||||
#include "bytestream.h"
|
#include "bytestream.h"
|
||||||
#include "timecode.h"
|
|
||||||
#include "libavutil/log.h"
|
#include "libavutil/log.h"
|
||||||
#include "libavutil/opt.h"
|
#include "libavutil/opt.h"
|
||||||
#include "libavutil/avassert.h"
|
#include "libavutil/avassert.h"
|
||||||
|
#include "libavutil/timecode.h"
|
||||||
|
|
||||||
static const uint8_t inv_non_linear_qscale[13] = {
|
static const uint8_t inv_non_linear_qscale[13] = {
|
||||||
0, 2, 4, 6, 8,
|
0, 2, 4, 6, 8,
|
||||||
@ -167,17 +167,20 @@ static av_cold int encode_init(AVCodecContext *avctx)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
s->drop_frame_timecode = s->tc.drop = s->drop_frame_timecode || !!(avctx->flags2 & CODEC_FLAG2_DROP_FRAME_TIMECODE);
|
s->drop_frame_timecode = s->drop_frame_timecode || !!(avctx->flags2 & CODEC_FLAG2_DROP_FRAME_TIMECODE);
|
||||||
|
if (s->drop_frame_timecode)
|
||||||
|
s->tc.flags |= AV_TIMECODE_FLAG_DROPFRAME;
|
||||||
if (s->drop_frame_timecode && s->frame_rate_index != 4) {
|
if (s->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");
|
av_log(avctx, AV_LOG_ERROR, "Drop frame time code only allowed with 1001/30000 fps\n");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (s->tc.str) {
|
if (s->tc_opt_str) {
|
||||||
s->tc.rate = avpriv_frame_rate_tab[s->frame_rate_index];
|
AVRational rate = avpriv_frame_rate_tab[s->frame_rate_index];
|
||||||
if (avpriv_init_smpte_timecode(s, &s->tc) < 0)
|
int ret = av_timecode_init_from_string(&s->tc, rate, s->tc_opt_str, s);
|
||||||
return -1;
|
if (ret < 0)
|
||||||
s->drop_frame_timecode = s->tc.drop;
|
return ret;
|
||||||
|
s->drop_frame_timecode = !!(s->tc.flags & AV_TIMECODE_FLAG_DROPFRAME);
|
||||||
s->avctx->timecode_frame_start = s->tc.start;
|
s->avctx->timecode_frame_start = s->tc.start;
|
||||||
} else {
|
} else {
|
||||||
s->avctx->timecode_frame_start = 0; // default is -1
|
s->avctx->timecode_frame_start = 0; // default is -1
|
||||||
@ -295,9 +298,9 @@ static void mpeg1_encode_sequence_header(MpegEncContext *s)
|
|||||||
time_code = s->current_picture_ptr->f.coded_picture_number + s->avctx->timecode_frame_start;
|
time_code = s->current_picture_ptr->f.coded_picture_number + s->avctx->timecode_frame_start;
|
||||||
|
|
||||||
s->gop_picture_number = s->current_picture_ptr->f.coded_picture_number;
|
s->gop_picture_number = s->current_picture_ptr->f.coded_picture_number;
|
||||||
av_assert0(s->drop_frame_timecode == s->tc.drop);
|
av_assert0(s->drop_frame_timecode == !!(s->tc.flags & AV_TIMECODE_FLAG_DROPFRAME));
|
||||||
if (s->tc.drop)
|
if (s->drop_frame_timecode)
|
||||||
time_code = avpriv_framenum_to_drop_timecode(time_code);
|
time_code = av_timecode_adjust_ntsc_framenum(time_code);
|
||||||
put_bits(&s->pb, 5, (uint32_t)((time_code / (fps * 3600)) % 24));
|
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, 6, (uint32_t)((time_code / (fps * 60)) % 60));
|
||||||
put_bits(&s->pb, 1, 1);
|
put_bits(&s->pb, 1, 1);
|
||||||
@ -928,7 +931,7 @@ static void mpeg1_encode_block(MpegEncContext *s,
|
|||||||
#define OFFSET(x) offsetof(MpegEncContext, x)
|
#define OFFSET(x) offsetof(MpegEncContext, x)
|
||||||
#define VE AV_OPT_FLAG_ENCODING_PARAM | AV_OPT_FLAG_VIDEO_PARAM
|
#define VE AV_OPT_FLAG_ENCODING_PARAM | AV_OPT_FLAG_VIDEO_PARAM
|
||||||
#define COMMON_OPTS\
|
#define COMMON_OPTS\
|
||||||
{TIMECODE_OPT(MpegEncContext,\
|
{AV_TIMECODE_OPTION(MpegEncContext, tc_opt_str, \
|
||||||
AV_OPT_FLAG_ENCODING_PARAM | AV_OPT_FLAG_VIDEO_PARAM)},\
|
AV_OPT_FLAG_ENCODING_PARAM | AV_OPT_FLAG_VIDEO_PARAM)},\
|
||||||
{ "intra_vlc", "Use MPEG-2 intra VLC table.", OFFSET(intra_vlc_format), AV_OPT_TYPE_INT, { 0 }, 0, 1, VE },\
|
{ "intra_vlc", "Use MPEG-2 intra VLC table.", OFFSET(intra_vlc_format), AV_OPT_TYPE_INT, { 0 }, 0, 1, VE },\
|
||||||
{ "drop_frame_timecode", "Timecode is in drop frame format.", OFFSET(drop_frame_timecode), AV_OPT_TYPE_INT, { 0 }, 0, 1, VE}, \
|
{ "drop_frame_timecode", "Timecode is in drop frame format.", OFFSET(drop_frame_timecode), AV_OPT_TYPE_INT, { 0 }, 0, 1, VE}, \
|
||||||
|
@ -36,7 +36,7 @@
|
|||||||
#include "parser.h"
|
#include "parser.h"
|
||||||
#include "mpeg12data.h"
|
#include "mpeg12data.h"
|
||||||
#include "rl.h"
|
#include "rl.h"
|
||||||
#include "timecode.h"
|
#include "libavutil/timecode.h"
|
||||||
|
|
||||||
#define FRAME_SKIPPED 100 ///< return value for header parsers if frame is not coded
|
#define FRAME_SKIPPED 100 ///< return value for header parsers if frame is not coded
|
||||||
|
|
||||||
@ -649,7 +649,8 @@ typedef struct MpegEncContext {
|
|||||||
/* RTP specific */
|
/* RTP specific */
|
||||||
int rtp_mode;
|
int rtp_mode;
|
||||||
|
|
||||||
struct ff_timecode tc;
|
char *tc_opt_str; ///< timecode option string
|
||||||
|
AVTimecode tc; ///< timecode context
|
||||||
|
|
||||||
uint8_t *ptr_lastgob;
|
uint8_t *ptr_lastgob;
|
||||||
int swap_uv; //vcr2 codec is an MPEG-2 variant with U and V swapped
|
int swap_uv; //vcr2 codec is an MPEG-2 variant with U and V swapped
|
||||||
|
Loading…
x
Reference in New Issue
Block a user