48 #if CONFIG_MPEG1VIDEO_ENCODER || CONFIG_MPEG2VIDEO_ENCODER
49 static const uint8_t svcd_scan_offset_placeholder[] = {
50 0x10, 0x0E, 0x00, 0x80, 0x81, 0x00, 0x80,
51 0x81, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
57 static uint8_t uni_mpeg1_ac_vlc_len[64 * 64 * 2];
58 static uint8_t uni_mpeg2_ac_vlc_len[64 * 64 * 2];
62 static uint32_t mpeg1_lum_dc_uni[512];
63 static uint32_t mpeg1_chr_dc_uni[512];
65 #define A53_MAX_CC_COUNT 0x1f
72 for (
i = 0;
i < 128;
i++) {
103 #if CONFIG_MPEG1VIDEO_ENCODER || CONFIG_MPEG2VIDEO_ENCODER
111 for (
i = 1;
i < 14;
i++) {
116 for (ext.
num=1; ext.
num <= 4; ext.
num++) {
117 for (ext.
den=1; ext.
den <= 32; ext.
den++) {
129 s->frame_rate_index =
i;
130 s->mpeg2_frame_rate_ext.num = ext.
num;
131 s->mpeg2_frame_rate_ext.den = ext.
den;
151 if (find_frame_rate_index(
s) < 0) {
158 "MPEG-1/2 does not support %d/%d fps, there may be AV sync issues\n",
181 "Only High(1) and 4:2:2(0) profiles support 4:2:2 color sampling\n");
186 else if (avctx->
width <= 1440)
193 if ((avctx->
width & 0xFFF) == 0 && (avctx->
height & 0xFFF) == 1) {
199 if ((avctx->
width & 0xFFF) == 0 || (avctx->
height & 0xFFF) == 0) {
200 av_log(avctx,
AV_LOG_ERROR,
"Width or Height are not allowed to be multiples of 4096\n"
207 if (
s->drop_frame_timecode)
209 if (
s->drop_frame_timecode &&
s->frame_rate_index != 4) {
211 "Drop frame time code only allowed with 1001/30000 fps\n");
215 #if FF_API_PRIVATE_OPT
228 s->timecode_frame_start =
s->tc.start;
230 s->timecode_frame_start = 0;
246 unsigned int vbv_buffer_size, fps, v;
247 int i, constraint_parameter_flag;
249 int64_t best_aspect_error = INT64_MAX;
250 AVRational aspect_ratio =
s->avctx->sample_aspect_ratio;
252 if (aspect_ratio.
num == 0 || aspect_ratio.
den == 0)
255 if (
s->current_picture.f->key_frame) {
264 for (
i = 1;
i < 15;
i++) {
265 int64_t
error = aspect_ratio.
num * (1LL<<32) / aspect_ratio.
den;
273 if (
error - 2 <= best_aspect_error) {
274 best_aspect_error =
error;
275 s->aspect_ratio_info =
i;
282 if (
s->avctx->rc_max_rate) {
283 v = (
s->avctx->rc_max_rate + 399) / 400;
290 if (
s->avctx->rc_buffer_size)
291 vbv_buffer_size =
s->avctx->rc_buffer_size;
295 vbv_buffer_size = ((20 *
s->bit_rate) / (1151929 / 2)) * 8 * 1024;
296 vbv_buffer_size = (vbv_buffer_size + 16383) / 16384;
302 constraint_parameter_flag =
305 s->mb_width *
s->mb_height <= 396 &&
308 s->avctx->me_range &&
309 s->avctx->me_range < 128 &&
310 vbv_buffer_size <= 20 &&
311 v <= 1856000 / 400 &&
314 put_bits(&
s->pb, 1, constraint_parameter_flag);
323 int use_seq_disp_ext;
339 put_bits(&
s->pb, 8, vbv_buffer_size >> 10);
341 put_bits(&
s->pb, 2,
s->mpeg2_frame_rate_ext.num-1);
342 put_bits(&
s->pb, 5,
s->mpeg2_frame_rate_ext.den-1);
353 use_seq_disp_ext = (
width !=
s->width ||
360 if (
s->seq_disp_ext == 1 || (
s->seq_disp_ext == -1 && use_seq_disp_ext)) {
365 put_bits(&
s->pb, 8,
s->avctx->color_primaries);
380 time_code =
s->current_picture_ptr->f->coded_picture_number +
381 s->timecode_frame_start;
383 s->gop_picture_number =
s->current_picture_ptr->f->coded_picture_number;
386 if (
s->drop_frame_timecode)
389 put_bits(&
s->pb, 5, (uint32_t)((time_code / (fps * 3600)) % 24));
390 put_bits(&
s->pb, 6, (uint32_t)((time_code / (fps * 60)) % 60));
392 put_bits(&
s->pb, 6, (uint32_t)((time_code / fps) % 60));
393 put_bits(&
s->pb, 6, (uint32_t)((time_code % fps)));
431 mpeg1_encode_sequence_header(
s);
439 (
s->picture_number -
s->gop_picture_number) & 0x3ff);
466 s->frame_pred_frame_dct = 1;
487 if (
s->progressive_sequence)
490 put_bits(&
s->pb, 1,
s->current_picture_ptr->f->top_field_first);
492 s->frame_pred_frame_dct =
s->progressive_sequence;
495 put_bits(&
s->pb, 1,
s->concealment_motion_vectors);
500 s->progressive_frame =
s->progressive_sequence;
507 if (
s->scan_offset) {
511 for (
i = 0;
i <
sizeof(svcd_scan_offset_placeholder);
i++)
512 put_bits(&
s->pb, 8, svcd_scan_offset_placeholder[
i]);
520 switch (stereo->
type) {
571 for (
i = 0;
i < side_data->
size;
i++)
577 "Warning Closed Caption size (%d) can not exceed 93 bytes "
578 "and must be a multiple of 3\n", side_data->
size);
588 int has_mv,
int field_motion)
591 if (!
s->frame_pred_frame_dct) {
609 int bit_size = f_or_b_code - 1;
610 int range = 1 << bit_size;
641 unsigned int diff_u =
diff + 255;
664 mpeg1_lum_dc_uni[
diff + 255] & 0xFF,
665 mpeg1_lum_dc_uni[
diff + 255] >> 8);
668 mpeg1_chr_dc_uni[
diff + 255] & 0xFF,
669 mpeg1_chr_dc_uni[
diff + 255] >> 8);
675 int alevel,
level, last_non_zero,
dc,
diff,
i, j,
run, last_index, sign;
679 last_index =
s->block_last_index[n];
683 component = (n <= 3 ? 0 : (n & 1) + 1);
685 diff =
dc -
s->last_dc[component];
687 s->last_dc[component] =
dc;
689 if (
s->intra_vlc_format)
707 last_non_zero =
i - 1;
709 for (;
i <= last_index;
i++) {
710 j =
s->intra_scantable.permutated[
i];
716 run =
i - last_non_zero - 1;
726 (table_vlc[
code][0] << 1) + sign);
729 put_bits(&
s->pb, table_vlc[111][1], table_vlc[111][0]);
749 put_bits(&
s->pb, table_vlc[112][1], table_vlc[112][0]);
753 int16_t
block[8][64],
754 int motion_x,
int motion_y,
758 const int mb_x =
s->mb_x;
759 const int mb_y =
s->mb_y;
760 const int first_mb = mb_x ==
s->resync_mb_x && mb_y ==
s->resync_mb_y;
764 for (
i = 0;
i < mb_block_count;
i++)
765 if (
s->block_last_index[
i] >= 0)
766 cbp |= 1 << (mb_block_count - 1 -
i);
769 (mb_x !=
s->mb_width - 1 ||
774 ? ((
s->mv[0][0][0] -
s->last_mv[0][0][0]) |
775 (
s->mv[0][0][1] -
s->last_mv[0][0][1])) : 0) |
777 ? ((
s->mv[1][0][0] -
s->last_mv[1][0][0]) |
778 (
s->mv[1][0][1] -
s->last_mv[1][0][1])) : 0)) == 0))) {
780 s->qscale -=
s->dquant;
785 s->last_mv[0][0][0] =
786 s->last_mv[0][0][1] =
787 s->last_mv[0][1][0] =
788 s->last_mv[0][1][1] = 0;
793 encode_mb_skip_run(
s,
s->mb_x);
795 encode_mb_skip_run(
s,
s->mb_skip_run);
799 if (
s->dquant && cbp) {
801 put_mb_modes(
s, 2, 1, 0, 0);
805 put_mb_modes(
s, 1, 1, 0, 0);
806 s->qscale -=
s->dquant;
810 }
else if (
s->mb_intra) {
811 if (
s->dquant && cbp) {
812 put_mb_modes(
s, 6, 0x01, 0, 0);
815 put_mb_modes(
s, 5, 0x03, 0, 0);
816 s->qscale -=
s->dquant;
820 memset(
s->last_mv, 0,
sizeof(
s->last_mv));
824 if ((motion_x | motion_y) == 0) {
827 put_mb_modes(
s, 5, 1, 0, 0);
831 put_mb_modes(
s, 2, 1, 0, 0);
836 put_mb_modes(
s, 5, 2, 1, 0);
839 put_mb_modes(
s, 1, 1, 1, 0);
843 mpeg1_encode_motion(
s,
844 motion_x -
s->last_mv[0][0][0],
847 mpeg1_encode_motion(
s,
848 motion_y -
s->last_mv[0][0][1],
854 if (!
s->frame_pred_frame_dct)
858 mpeg1_encode_motion(
s,
859 motion_x -
s->last_mv[0][0][0],
862 mpeg1_encode_motion(
s,
863 motion_y -
s->last_mv[0][0][1],
865 s->qscale -=
s->dquant;
868 s->last_mv[0][1][0] =
s->last_mv[0][0][0] = motion_x;
869 s->last_mv[0][1][1] =
s->last_mv[0][0][1] = motion_y;
875 put_mb_modes(
s, 5, 2, 1, 1);
878 put_mb_modes(
s, 1, 1, 1, 1);
883 s->qscale -=
s->dquant;
886 for (
i = 0;
i < 2;
i++) {
888 mpeg1_encode_motion(
s,
889 s->mv[0][
i][0] -
s->last_mv[0][
i][0],
891 mpeg1_encode_motion(
s,
892 s->mv[0][
i][1] - (
s->last_mv[0][
i][1] >> 1),
894 s->last_mv[0][
i][0] =
s->mv[0][
i][0];
895 s->last_mv[0][
i][1] = 2 *
s->mv[0][
i][1];
900 if (
s->chroma_y_shift) {
917 put_mb_modes(
s, 6, 3, 1, 0);
919 put_mb_modes(
s, 8 -
s->mv_dir, 2, 1, 0);
922 put_mb_modes(
s, 5 -
s->mv_dir, 3, 1, 0);
926 if (!
s->frame_pred_frame_dct)
928 s->qscale -=
s->dquant;
932 mpeg1_encode_motion(
s,
933 s->mv[0][0][0] -
s->last_mv[0][0][0],
935 mpeg1_encode_motion(
s,
936 s->mv[0][0][1] -
s->last_mv[0][0][1],
938 s->last_mv[0][0][0] =
939 s->last_mv[0][1][0] =
s->mv[0][0][0];
940 s->last_mv[0][0][1] =
941 s->last_mv[0][1][1] =
s->mv[0][0][1];
945 mpeg1_encode_motion(
s,
946 s->mv[1][0][0] -
s->last_mv[1][0][0],
948 mpeg1_encode_motion(
s,
949 s->mv[1][0][1] -
s->last_mv[1][0][1],
951 s->last_mv[1][0][0] =
952 s->last_mv[1][1][0] =
s->mv[1][0][0];
953 s->last_mv[1][0][1] =
954 s->last_mv[1][1][1] =
s->mv[1][0][1];
963 put_mb_modes(
s, 6, 3, 1, 1);
965 put_mb_modes(
s, 8 -
s->mv_dir, 2, 1, 1);
968 put_mb_modes(
s, 5 -
s->mv_dir, 3, 1, 1);
973 s->qscale -=
s->dquant;
977 for (
i = 0;
i < 2;
i++) {
979 mpeg1_encode_motion(
s,
980 s->mv[0][
i][0] -
s->last_mv[0][
i][0],
982 mpeg1_encode_motion(
s,
983 s->mv[0][
i][1] - (
s->last_mv[0][
i][1] >> 1),
985 s->last_mv[0][
i][0] =
s->mv[0][
i][0];
986 s->last_mv[0][
i][1] =
s->mv[0][
i][1] * 2;
991 for (
i = 0;
i < 2;
i++) {
993 mpeg1_encode_motion(
s,
994 s->mv[1][
i][0] -
s->last_mv[1][
i][0],
996 mpeg1_encode_motion(
s,
997 s->mv[1][
i][1] - (
s->last_mv[1][
i][1] >> 1),
999 s->last_mv[1][
i][0] =
s->mv[1][
i][0];
1000 s->last_mv[1][
i][1] =
s->mv[1][
i][1] * 2;
1007 if (
s->chroma_y_shift) {
1019 for (
i = 0;
i < mb_block_count;
i++)
1020 if (cbp & (1 << (mb_block_count - 1 -
i)))
1021 mpeg1_encode_block(
s,
block[
i],
i);
1031 int motion_x,
int motion_y)
1034 mpeg1_encode_mb_internal(
s,
block, motion_x, motion_y, 6);
1036 mpeg1_encode_mb_internal(
s,
block, motion_x, motion_y, 8);
1039 static av_cold void mpeg12_encode_init_static(
void)
1050 for (
int i = -255;
i < 256;
i++) {
1063 mpeg1_lum_dc_uni[
i + 255] =
bits + (
code << 8);
1068 mpeg1_chr_dc_uni[
i + 255] =
bits + (
code << 8);
1071 for (
int f_code = 1; f_code <=
MAX_FCODE; f_code++)
1080 bit_size = f_code - 1;
1099 for (
int f_code =
MAX_FCODE; f_code > 0; f_code--)
1100 for (
int mv = -(8 << f_code);
mv < (8 << f_code);
mv++)
1113 s->min_qcoeff = -255;
1114 s->max_qcoeff = 255;
1116 s->min_qcoeff = -2047;
1117 s->max_qcoeff = 2047;
1119 if (
s->intra_vlc_format) {
1120 s->intra_ac_vlc_length =
1121 s->intra_ac_vlc_last_length = uni_mpeg2_ac_vlc_len;
1123 s->intra_ac_vlc_length =
1124 s->intra_ac_vlc_last_length = uni_mpeg1_ac_vlc_len;
1126 s->inter_ac_vlc_length =
1127 s->inter_ac_vlc_last_length = uni_mpeg1_ac_vlc_len;
1132 #define OFFSET(x) offsetof(MpegEncContext, x)
1133 #define VE AV_OPT_FLAG_ENCODING_PARAM | AV_OPT_FLAG_VIDEO_PARAM
1134 #define COMMON_OPTS \
1135 { "gop_timecode", "MPEG GOP Timecode in hh:mm:ss[:;.]ff format. Overrides timecode_frame_start.", \
1136 OFFSET(tc_opt_str), AV_OPT_TYPE_STRING, {.str=NULL}, 0, 0, VE },\
1137 { "drop_frame_timecode", "Timecode is in drop frame format.", \
1138 OFFSET(drop_frame_timecode), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, VE }, \
1139 { "scan_offset", "Reserve space for SVCD scan offset user data.", \
1140 OFFSET(scan_offset), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, VE }, \
1141 { "timecode_frame_start", "GOP timecode frame start number, in non-drop-frame format", \
1142 OFFSET(timecode_frame_start), AV_OPT_TYPE_INT64, {.i64 = -1 }, -1, INT64_MAX, VE}, \
1144 static const AVOption mpeg1_options[] = {
1150 static const AVOption mpeg2_options[] = {
1152 {
"intra_vlc",
"Use MPEG-2 intra VLC table.",
1154 {
"non_linear_quant",
"Use nonlinear quantizer.",
OFFSET(q_scale_type),
AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1,
VE },
1155 {
"alternate_scan",
"Enable alternate scantable.",
OFFSET(alternate_scan),
AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1,
VE },
1156 {
"seq_disp_ext",
"Write sequence_display_extension blocks.",
OFFSET(seq_disp_ext),
AV_OPT_TYPE_INT, { .i64 = -1 }, -1, 1,
VE,
"seq_disp_ext" },
1167 #define LEVEL(name, value) name, NULL, 0, AV_OPT_TYPE_CONST, { .i64 = value }, 0, 0, VE, "avctx.level"
1168 {
LEVEL(
"high", 4) },
1169 {
LEVEL(
"high1440", 6) },
1170 {
LEVEL(
"main", 8) },
1171 {
LEVEL(
"low", 10) },
1178 #define mpeg12_class(x) \
1179 static const AVClass mpeg ## x ## _class = { \
1180 .class_name = "mpeg" # x "video encoder", \
1181 .item_name = av_default_item_name, \
1182 .option = mpeg ## x ## _options, \
1183 .version = LIBAVUTIL_VERSION_INT, \
1190 .
name =
"mpeg1video",
1203 .priv_class = &mpeg1_class,
1207 .
name =
"mpeg2video",
1221 .priv_class = &mpeg2_class,
static double val(void *priv, double ch)
AVCodec ff_mpeg1video_encoder
AVCodec ff_mpeg2video_encoder
static int64_t put_header(AVIOContext *pb, const ff_asf_guid *g)
static av_cold int encode_init(AVCodecContext *avctx)
Macro definitions for various function/variable attributes.
uint8_t pi<< 24) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_U8, uint8_t,(*(const uint8_t *) pi - 0x80) *(1.0f/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_U8, uint8_t,(*(const uint8_t *) pi - 0x80) *(1.0/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S16, int16_t,(*(const int16_t *) pi >> 8)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S16, int16_t, *(const int16_t *) pi *(1.0f/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S16, int16_t, *(const int16_t *) pi *(1.0/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S32, int32_t,(*(const int32_t *) pi >> 24)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S32, int32_t, *(const int32_t *) pi *(1.0f/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S32, int32_t, *(const int32_t *) pi *(1.0/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_FLT, float, av_clip_uint8(lrintf(*(const float *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_FLT, float, av_clip_int16(lrintf(*(const float *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_FLT, float, av_clipl_int32(llrintf(*(const float *) pi *(1U<< 31)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_DBL, double, av_clip_uint8(lrint(*(const double *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_DBL, double, av_clip_int16(lrint(*(const double *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_DBL, double, av_clipl_int32(llrint(*(const double *) pi *(1U<< 31)))) #define SET_CONV_FUNC_GROUP(ofmt, ifmt) static void set_generic_function(AudioConvert *ac) { } void ff_audio_convert_free(AudioConvert **ac) { if(! *ac) return;ff_dither_free(&(*ac) ->dc);av_freep(ac);} AudioConvert *ff_audio_convert_alloc(AVAudioResampleContext *avr, enum AVSampleFormat out_fmt, enum AVSampleFormat in_fmt, int channels, int sample_rate, int apply_map) { AudioConvert *ac;int in_planar, out_planar;ac=av_mallocz(sizeof(*ac));if(!ac) return NULL;ac->avr=avr;ac->out_fmt=out_fmt;ac->in_fmt=in_fmt;ac->channels=channels;ac->apply_map=apply_map;if(avr->dither_method !=AV_RESAMPLE_DITHER_NONE &&av_get_packed_sample_fmt(out_fmt)==AV_SAMPLE_FMT_S16 &&av_get_bytes_per_sample(in_fmt) > 2) { ac->dc=ff_dither_alloc(avr, out_fmt, in_fmt, channels, sample_rate, apply_map);if(!ac->dc) { av_free(ac);return NULL;} return ac;} in_planar=ff_sample_fmt_is_planar(in_fmt, channels);out_planar=ff_sample_fmt_is_planar(out_fmt, channels);if(in_planar==out_planar) { ac->func_type=CONV_FUNC_TYPE_FLAT;ac->planes=in_planar ? ac->channels :1;} else if(in_planar) ac->func_type=CONV_FUNC_TYPE_INTERLEAVE;else ac->func_type=CONV_FUNC_TYPE_DEINTERLEAVE;set_generic_function(ac);if(ARCH_AARCH64) ff_audio_convert_init_aarch64(ac);if(ARCH_ARM) ff_audio_convert_init_arm(ac);if(ARCH_X86) ff_audio_convert_init_x86(ac);return ac;} int ff_audio_convert(AudioConvert *ac, AudioData *out, AudioData *in) { int use_generic=1;int len=in->nb_samples;int p;if(ac->dc) { av_log(ac->avr, AV_LOG_TRACE, "%d samples - audio_convert: %s to %s (dithered)\n", len, av_get_sample_fmt_name(ac->in_fmt), av_get_sample_fmt_name(ac->out_fmt));return ff_convert_dither(ac-> dc
simple assert() macros that are a bit more flexible than ISO C assert().
#define av_assert2(cond)
assert() equivalent, that does lie in speed critical code.
#define av_assert0(cond)
assert() equivalent, that is always enabled.
Libavcodec external API header.
#define FF_COMPLIANCE_UNOFFICIAL
Allow unofficial extensions.
#define FF_COMPLIANCE_EXPERIMENTAL
Allow nonstandardized experimental things.
#define FF_PROFILE_UNKNOWN
#define FF_PROFILE_MPEG2_MAIN
#define FF_PROFILE_MPEG2_422
#define FF_PROFILE_MPEG2_HIGH
static av_cold int init(AVCodecContext *avctx)
#define FFABS(a)
Absolute value, Note, INT_MIN / INT64_MIN result in undefined behavior as they are not representable ...
#define AV_CODEC_CAP_DELAY
Encoder or decoder requires flushing with NULL input at the end in order to give the complete and cor...
#define AV_CODEC_FLAG_CLOSED_GOP
#define AV_CODEC_CAP_SLICE_THREADS
Codec supports slice-based (or partition-based) multithreading.
#define AV_CODEC_FLAG2_DROP_FRAME_TIMECODE
timecode is in drop frame format.
@ AV_CODEC_ID_MPEG2VIDEO
preferred ID for MPEG-1/2 video decoding
AVFrameSideData * av_frame_get_side_data(const AVFrame *frame, enum AVFrameSideDataType type)
@ AV_FRAME_DATA_PANSCAN
The data is the AVPanScan struct defined in libavcodec.
@ AV_FRAME_DATA_A53_CC
ATSC A53 Part 4 Closed Captions.
@ AV_FRAME_DATA_STEREO3D
Stereoscopic 3d metadata.
#define AV_LOG_WARNING
Something somehow does not look correct.
#define AV_LOG_INFO
Standard information.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
int av_nearer_q(AVRational q, AVRational q1, AVRational q2)
Find which of the two rationals is closer to another rational.
AVRational av_mul_q(AVRational b, AVRational c)
Multiply two rationals.
static int av_cmp_q(AVRational a, AVRational b)
Compare two rationals.
static av_always_inline AVRational av_inv_q(AVRational q)
Invert a rational.
int64_t av_gcd(int64_t a, int64_t b)
Compute the greatest common divisor of two integer operands.
@ AV_PICTURE_TYPE_I
Intra.
@ AV_PICTURE_TYPE_P
Predicted.
@ AV_PICTURE_TYPE_B
Bi-dir predicted.
@ AV_STEREO3D_2D
Video is not stereoscopic (and metadata has to be there).
@ AV_STEREO3D_TOPBOTTOM
Views are on top of each other.
@ AV_STEREO3D_SIDEBYSIDE_QUINCUNX
Views are next to each other, but when upscaling apply a checkerboard pattern.
@ AV_STEREO3D_SIDEBYSIDE
Views are next to each other.
static uint8_t fcode_tab[MAX_MV *2+1]
Minimal fcode that a motion vector component would need.
static uint8_t mv_penalty[MAX_FCODE+1][MAX_DMV *2+1]
Table of number of bits a motion vector component needs.
static void put_bits(Jpeg2000EncoderContext *s, int val, int n)
put n times val bit
static const int8_t mv[256][2]
#define FF_CODEC_CAP_INIT_THREADSAFE
The codec does not modify any global variables in the init function, allowing to call the init functi...
#define FF_CODEC_CAP_INIT_CLEANUP
The codec allows calling the close function for deallocation even if the init function returned a fai...
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
#define FF_DISABLE_DEPRECATION_WARNINGS
#define FF_ENABLE_DEPRECATION_WARNINGS
static int ff_thread_once(char *control, void(*routine)(void))
static enum AVPixelFormat pix_fmts[]
static av_const int sign_extend(int val, unsigned bits)
#define MASK_ABS(mask, level)
av_cold void ff_mpeg12_common_init(MpegEncContext *s)
void ff_mpeg1_encode_slice_header(MpegEncContext *s)
void ff_mpeg1_encode_mb(MpegEncContext *s, int16_t block[8][64], int motion_x, int motion_y)
void ff_mpeg1_encode_picture_header(MpegEncContext *s, int picture_number)
void ff_mpeg1_encode_init(MpegEncContext *s)
const uint16_t ff_mpeg12_vlc_dc_chroma_code[12]
const uint8_t ff_mpeg12_mbPatTable[64][2]
const uint8_t ff_mpeg12_mbAddrIncrTable[36][2]
const uint16_t ff_mpeg12_vlc_dc_lum_code[12]
const float ff_mpeg1_aspect[16]
const uint8_t ff_mpeg12_mbMotionVectorTable[17][2]
const AVRational ff_mpeg2_aspect[16]
const unsigned char ff_mpeg12_vlc_dc_chroma_bits[12]
const AVRational ff_mpeg2_frame_rate_tab[]
const unsigned char ff_mpeg12_vlc_dc_lum_bits[12]
const AVRational ff_mpeg12_frame_rate_tab[]
av_cold void ff_mpeg1_init_uni_ac_vlc(const RLTable *rl, uint8_t *uni_ac_vlc_len)
#define PICTURE_START_CODE
#define VIDEO_FORMAT_NTSC
int ff_mpv_encode_end(AVCodecContext *avctx)
int ff_mpv_encode_picture(AVCodecContext *avctx, AVPacket *pkt, const AVFrame *frame, int *got_packet)
static int get_bits_diff(MpegEncContext *s)
#define VIDEO_FORMAT_UNSPECIFIED
#define VIDEO_FORMAT_COMPONENT
#define SLICE_MIN_START_CODE
#define MV_TYPE_FIELD
2 vectors, one per field
#define UNI_AC_ENC_INDEX(run, level)
#define VIDEO_FORMAT_SECAM
void ff_write_quant_matrix(PutBitContext *pb, uint16_t *matrix)
#define FF_MPV_COMMON_OPTS
#define MV_TYPE_16X16
1 vector for the whole mb
int ff_mpv_encode_init(AVCodecContext *avctx)
AVPixelFormat
Pixel format.
@ AV_PIX_FMT_YUV420P
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
@ AV_PIX_FMT_YUV422P
planar YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples)
#define FF_MPEG2_PROFILE_OPTS
static void put_sbits(PutBitContext *pb, int n, int32_t value)
static int put_bits_count(PutBitContext *s)
static void align_put_bits(PutBitContext *s)
Pad the bitstream with zeros up to the next byte boundary.
av_cold void ff_rl_init(RLTable *rl, uint8_t static_store[2][2 *MAX_RUN+MAX_LEVEL+3])
static const uint8_t header[24]
static void encode_dc(PutBitContext *pb, int diff, int component)
main external API structure.
int width
picture width / height.
int flags2
AV_CODEC_FLAG2_*.
attribute_deprecated int64_t timecode_frame_start
AVRational time_base
This is the fundamental unit of time (in seconds) in terms of which frame timestamps are represented.
const char * name
Name of the codec implementation.
Structure to hold side data for an AVFrame.
int width
width and height in 1/16 pel
Rational number (pair of numerator and denominator).
Stereo 3D type: this structure describes how two videos are packed within a single video surface,...
enum AVStereo3DType type
How views are packed within the video.
uint8_t * index_run[2]
encoding only
const uint16_t(* table_vlc)[2]
int8_t * max_level[2]
encoding & decoding
static void error(const char *err)
int av_timecode_init_from_string(AVTimecode *tc, AVRational rate, const char *str, void *log_ctx)
Parse timecode representation (hh:mm:ss[:;.
int av_timecode_adjust_ntsc_framenum2(int framenum, int fps)
Adjust frame number for NTSC drop frame time code.
@ AV_TIMECODE_FLAG_DROPFRAME
timecode is drop frame
static av_always_inline int diff(const uint32_t a, const uint32_t b)