28 #include "libavutil/attributes.h"
57 #define MB_TYPE_ZERO_MV 0x20000000
84 0, 1, 2, 3, 4, 5, 6, 7,
85 8,10,12,14,16,18,20,22,
86 24,28,32,36,40,44,48,52,
87 56,64,72,80,88,96,104,112,
107 val = (val - 1) << shift;
126 const int qscale = s->
qscale;
129 component = (n <= 3 ? 0 : n - 4 + 1);
136 block[0] = dc * quant_matrix[0];
148 }
else if (level != 0) {
151 level = (level * qscale * quant_matrix[j]) >> 4;
152 level = (level - 1) | 1;
162 }
else if (level == 0) {
169 level = (level * qscale * quant_matrix[j]) >> 4;
170 level = (level - 1) | 1;
173 level = (level * qscale * quant_matrix[j]) >> 4;
174 level = (level - 1) | 1;
201 const int qscale = s->
qscale;
209 level = (3 * qscale * quant_matrix[0]) >> 5;
210 level = (level - 1) | 1;
226 level = ((level * 2 + 1) * qscale * quant_matrix[j]) >> 5;
227 level = (level - 1) | 1;
237 }
else if (level == 0) {
244 level = ((level * 2 + 1) * qscale * quant_matrix[j]) >> 5;
245 level = (level - 1) | 1;
248 level = ((level * 2 + 1) * qscale * quant_matrix[j]) >> 5;
249 level = (level - 1) | 1;
280 const int qscale = s->
qscale;
288 level = (3 * qscale) >> 1;
289 level = (level - 1) | 1;
306 level = ((level * 2 + 1) * qscale) >> 1;
307 level = (level - 1) | 1;
317 }
else if (level == 0) {
324 level = ((level * 2 + 1) * qscale) >> 1;
325 level = (level - 1) | 1;
328 level = ((level * 2 + 1) * qscale) >> 1;
329 level = (level - 1) | 1;
352 const uint16_t *quant_matrix;
353 const int qscale = s->
qscale;
369 level= (3 * qscale * quant_matrix[0]) >> 5;
387 level = ((level * 2 + 1) * qscale * quant_matrix[j]) >> 5;
399 level = ((-level * 2 + 1) * qscale * quant_matrix[j]) >> 5;
402 level = ((level * 2 + 1) * qscale * quant_matrix[j]) >> 5;
420 block[63] ^= (mismatch & 1);
437 const int qscale = s->
qscale;
444 level = (3 * qscale) >> 1;
461 level = ((level * 2 + 1) * qscale) >> 1;
473 level = ((-level * 2 + 1) * qscale) >> 1;
476 level = ((level * 2 + 1) * qscale) >> 1;
499 const uint16_t *quant_matrix;
500 const int qscale = s->
qscale;
509 component = (n & 1) + 1;
519 mismatch = block[0] ^ 1;
535 }
else if (level != 0) {
538 level = (level * qscale * quant_matrix[j]) >> 4;
549 level = (-level * qscale * quant_matrix[j]) >> 4;
552 level = (level * qscale * quant_matrix[j]) >> 4;
565 block[63] ^= mismatch & 1;
582 const uint16_t *quant_matrix;
583 const int qscale = s->
qscale;
591 component = (n & 1) + 1;
614 }
else if (level != 0) {
617 level = (level * qscale * quant_matrix[j]) >> 4;
628 level = (-level * qscale * quant_matrix[j]) >> 4;
631 level = (level * qscale * quant_matrix[j]) >> 4;
682 int i, j, k, cbp,
val, mb_type, motion_type;
707 if ((s->
mv[0][0][0] | s->
mv[0][0][1] | s->
mv[1][0][0] | s->
mv[1][0][1]) == 0)
786 for (i = 0; i < 6; i++) {
790 for (i = 0; i < mb_block_count; i++) {
796 for (i = 0; i < 6; i++) {
842 s->
mv_dir = (mb_type >> 13) & 3;
844 switch (motion_type) {
849 for (i = 0; i < 2; i++) {
858 s->
mv[i][0][0] <<= 1;
859 s->
mv[i][0][1] <<= 1;
866 for (i = 0; i < 2; i++) {
869 for (j = 0; j < 2; j++) {
871 for (k = 0; k < 2; k++) {
875 s->
mv[i][j][k] =
val;
886 for (i = 0; i < 2; i++) {
888 for (j = 0; j < 2; j++) {
893 s->
mv[i][j][0] =
val;
897 s->
last_mv[i][j][1] = val << 1;
898 s->
mv[i][j][1] =
val;
906 for (i = 0; i < 2; i++) {
909 for (k = 0; k < 2; k++) {
914 s->
mv[i][0][k] =
val;
926 for (i = 0; i < 2; i++) {
928 int dmx, dmy, mx, my,
m;
937 s->
last_mv[i][0][1] >> my_shift);
941 s->
last_mv[i][0][1] = my << my_shift;
942 s->
last_mv[i][1][1] = my << my_shift;
956 s->
mv[i][2][0] = ((mx * m + (mx > 0)) >> 1) + dmx;
957 s->
mv[i][2][1] = ((my * m + (my > 0)) >> 1) + dmy - 1;
959 s->
mv[i][3][0] = ((mx * m + (mx > 0)) >> 1) + dmx;
960 s->
mv[i][3][1] = ((my * m + (my > 0)) >> 1) + dmy + 1;
964 s->
mv[i][2][0] = ((mx + (mx > 0)) >> 1) + dmx;
965 s->
mv[i][2][1] = ((my + (my > 0)) >> 1) + dmy;
985 if (mb_block_count > 6) {
986 cbp <<= mb_block_count - 6;
1005 for (i = 0; i < 6; i++) {
1014 cbp <<= 12-mb_block_count;
1016 for (i = 0; i < mb_block_count; i++) {
1017 if (cbp & (1 << 11)) {
1028 for (i = 0; i < 6; i++) {
1037 for (i = 0; i < 6; i++) {
1049 for (i = 0; i < 12; i++)
1067 for (i = 0; i < 64; i++)
1096 if (avctx == avctx_from || !ctx_from->mpeg_enc_ctx_allocated || !
s1->context_initialized)
1100 if (err)
return err;
1114 uint16_t temp_matrix[64];
1117 memcpy(temp_matrix, matrix, 64 *
sizeof(uint16_t));
1119 for (i = 0; i < 64; i++) {
1120 matrix[new_perm[i]] = temp_matrix[old_perm[i]];
1125 #if CONFIG_MPEG_XVMC_DECODER
1129 #if CONFIG_MPEG1_VDPAU_HWACCEL
1138 #if CONFIG_MPEG_XVMC_DECODER
1142 #if CONFIG_MPEG2_VDPAU_HWACCEL
1146 #if CONFIG_MPEG2_DXVA2_HWACCEL
1149 #if CONFIG_MPEG2_VAAPI_HWACCEL
1280 s->avctx->sample_aspect_ratio =
1290 memcpy(old_permutation,
s->dsp.idct_permutation, 64 *
sizeof(
uint8_t));
1300 s1->mpeg_enc_ctx_allocated = 1;
1310 int ref, f_code, vbv_delay;
1353 int horiz_size_ext, vert_size_ext;
1363 s->
width |= (horiz_size_ext << 12);
1364 s->
height |= (vert_size_ext << 12);
1366 s->
bit_rate += (bit_rate_ext << 18) * 400;
1389 int color_description, w, h;
1393 if (color_description) {
1429 for (i = 0; i < nofco; i++) {
1447 for (i = 0; i < 64; i++) {
1454 if (intra && i == 0 && v != 8) {
1584 for (i = 0; i < 4; i++) {
1606 #define DECODE_SLICE_ERROR -1
1607 #define DECODE_SLICE_OK 0
1676 const uint8_t *buf_end, *buf_start = *buf - 4;
1679 if (buf_end < *buf + buf_size)
1695 av_log(s->
avctx,
AV_LOG_DEBUG,
"qp:%d fc:%2d%2d%2d%2d %s %s %s %s %s dc:%d pstruct:%d fdct:%d cmv:%d qtype:%d ivlc:%d rff:%d %s\n",
1716 int motion_x, motion_y, dir, i;
1718 for (i = 0; i < 2; i++) {
1719 for (dir = 0; dir < 2; dir++) {
1721 motion_x = motion_y = 0;
1723 motion_x = s->
mv[dir][0][0];
1724 motion_y = s->
mv[dir][0][1];
1726 motion_x = s->
mv[dir][i][0];
1727 motion_y = s->
mv[dir][i][1];
1756 s->
mb_y += 1 << field_pic;
1764 if (left >= 32 && !is_d10) {
1798 }
else if (code == 35) {
1820 for (i = 0; i < 12; i++)
1829 s->
mv[0][0][0] = s->
mv[0][0][1] = 0;
1864 av_dlog(c,
"ret:%d resync:%d/%d mb:%d/%d ts:%d/%d ec:%d\n",
1883 mb_y += (*buf&0xE0)<<2;
1887 if (mb_y < 0 || mb_y >= s->
end_mb_y)
1958 if (width == 0 || height == 0) {
1986 for (i = 0; i < 64; i++) {
1996 for (i = 0; i < 64; i++) {
2053 for (i = 0; i < 64; i++) {
2084 const uint8_t *p,
int buf_size)
2087 const uint8_t *buf_end = p + buf_size;
2092 if(!memcmp(p+i,
"\0TMPGEXS\0", 9)){
2103 if (buf_end - p >= 5 &&
2104 p[0] ==
'D' && p[1] ==
'T' && p[2] ==
'G' && p[3] ==
'1') {
2112 if (buf_end - p < 1)
2141 "GOP (%s) closed_gop=%d broken_link=%d\n",
2147 AVFrame *picture,
int *got_output,
2153 const uint8_t *buf_end = buf + buf_size;
2154 int ret, input_size;
2155 int last_code = 0, skip_frame = 0;
2156 int picture_start_code_seen = 0;
2162 if (start_code > 0x1ff) {
2190 input_size = buf_end - buf_ptr;
2193 av_log(avctx,
AV_LOG_DEBUG,
"%3X at %td left %d\n", start_code, buf_ptr-buf, input_size);
2197 switch (start_code) {
2199 if (last_code == 0) {
2217 picture_start_code_seen = 1;
2263 if (last_code == 0) {
2295 if (last_code == 0) {
2338 mb_y += (*buf_ptr&0xE0)<<2;
2344 if (buf_end - buf_ptr < 2) {
2416 if (threshold <= mb_y) {
2452 void *
data,
int *got_output,
2457 int buf_size = avpkt->
size;
2461 av_dlog(avctx,
"fill_buffer\n");
2505 ret =
decode_chunks(avctx, picture, got_output, buf, buf_size);
2506 if (ret<0 || *got_output)
2545 .
name =
"mpeg1video",
2562 .
name =
"mpeg2video",
2580 .
name =
"mpegvideo",
2593 #if CONFIG_MPEG_XVMC_DECODER
2601 av_dlog(avctx,
"mpeg12.c: XvMC decoder will work better if SLICE_FLAG_ALLOW_FIELD is set\n");
2611 AVCodec ff_mpeg_xvmc_decoder = {
2612 .
name =
"mpegvideo_xvmc",
2617 .
init = mpeg_mc_decode_init,
2627 #if CONFIG_MPEG_VDPAU_DECODER
2628 AVCodec ff_mpeg_vdpau_decoder = {
2629 .
name =
"mpegvideo_vdpau",
2643 #if CONFIG_MPEG1_VDPAU_DECODER
2644 AVCodec ff_mpeg1_vdpau_decoder = {
2645 .
name =
"mpeg1video_vdpau",
static const uint32_t btype2mb_type[11]
const uint16_t ff_mpeg1_default_non_intra_matrix[64]
#define PICT_BOTTOM_FIELD
const char const char void * val
discard all frames except keyframes
void ff_init_block_index(MpegEncContext *s)
int(* start_frame)(AVCodecContext *avctx, const uint8_t *buf, uint32_t buf_size)
Called at the beginning of each frame or field picture.
#define CONFIG_MPEG_XVMC_DECODER
#define CODEC_CAP_HWACCEL
#define CODEC_FLAG2_FAST
Allow non spec compliant speedup tricks.
#define SLICE_MAX_START_CODE
static int shift(int a, int b)
This structure describes decoded (raw) audio or video data.
static void quant_matrix_rebuild(uint16_t *matrix, const uint8_t *old_perm, const uint8_t *new_perm)
int start_mb_y
start mb_y of this thread (so current thread should process start_mb_y <= row < end_mb_y) ...
#define MV_TYPE_FIELD
2 vectors, one per field
static const AVProfile profiles[]
int last_mv[2][2][2]
last MV, used for MV prediction in MPEG1 & B-frame MPEG4
int coded_width
Bitstream width / height, may be different from width/height e.g.
static const AVProfile mpeg2_video_profiles[]
av_cold int ff_MPV_common_init(MpegEncContext *s)
init common structure for both encoder and decoder.
static void mpeg_decode_sequence_display_extension(Mpeg1Context *s1)
int sync
Did we reach a sync point like a GOP/SEQ/KEYFrame?
static unsigned int get_bits(GetBitContext *s, int n)
Read 1-25 bits.
#define AV_LOG_WARNING
Something somehow does not look correct.
av_cold void ff_mpeg12_init_vlcs(void)
void ff_MPV_report_decode_progress(MpegEncContext *s)
int end_mb_y
end mb_y of this thread (so current thread should process start_mb_y <= row < end_mb_y) ...
static av_cold int init(AVCodecContext *avctx)
#define CODEC_CAP_TRUNCATED
uint16_t chroma_intra_matrix[64]
enum AVPixelFormat ff_thread_get_format(AVCodecContext *avctx, const enum AVPixelFormat *fmt)
Wrapper around get_format() for frame-multithreaded codecs.
int v_edge_pos
horizontal / vertical position of the right/bottom edge (pixel replication)
uint16_t chroma_inter_matrix[64]
void ff_er_frame_end(ERContext *s)
static int mpeg2_fast_decode_block_non_intra(MpegEncContext *s, int16_t *block, int n)
Note: this function can read out of range and crash for corrupt streams.
enum AVColorRange color_range
MPEG vs JPEG YUV range.
planar YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples)
int repeat_pict
When decoding, this signals how much the picture must be delayed.
void ff_xvmc_field_end(MpegEncContext *s)
Complete frame/field rendering by passing any remaining blocks.
void avcodec_set_dimensions(AVCodecContext *s, int width, int height)
HW decoding through DXVA2, Picture.data[3] contains a LPDIRECT3DSURFACE9 pointer. ...
static void mpeg_decode_picture_coding_extension(Mpeg1Context *s1)
void ff_mpeg1_clean_buffers(MpegEncContext *s)
AVRational sample_aspect_ratio
sample aspect ratio (0 if unknown) That is the width of a pixel divided by the height of the pixel...
AVCodec ff_mpeg1video_decoder
void av_log(void *avcl, int level, const char *fmt,...) av_printf_format(3
Send the specified message to the log if the level is less than or equal to the current av_log_level...
enum AVPixelFormat pix_fmt
Pixel format, see AV_PIX_FMT_xxx.
static int av_cmp_q(AVRational a, AVRational b)
Compare two rationals.
static av_cold int mpeg_decode_init(AVCodecContext *avctx)
The data is the AVPanScan struct defined in libavcodec.
av_dlog(ac->avr,"%d samples - audio_convert: %s to %s (%s)\n", len, av_get_sample_fmt_name(ac->in_fmt), av_get_sample_fmt_name(ac->out_fmt), use_generic?ac->func_descr_generic:ac->func_descr)
static void mpeg_decode_gop(AVCodecContext *avctx, const uint8_t *buf, int buf_size)
#define SLICE_MIN_START_CODE
#define FF_PROFILE_MPEG2_422
int ff_xvmc_field_start(MpegEncContext *s, AVCodecContext *avctx)
Find and store the surfaces that are used as reference frames.
static int get_dmv(MpegEncContext *s)
static int get_sbits(GetBitContext *s, int n)
int encoding
true if we are encoding (vs decoding)
uint8_t * extradata
some codecs need / can use extradata like Huffman tables.
#define USES_LIST(a, list)
does this mb use listX, note does not work if subMBs
AVRational time_base
This is the fundamental unit of time (in seconds) in terms of which frame timestamps are represented...
if((e=av_dict_get(options,"", NULL, AV_DICT_IGNORE_SUFFIX)))
enum AVDiscard skip_frame
Skip decoding for selected frames.
static int mpeg_decode_update_thread_context(AVCodecContext *avctx, const AVCodecContext *avctx_from)
#define FF_PROFILE_MPEG2_MAIN
MPEG-1 HW decoding with VDPAU, data[0] contains a vdpau_render_state struct which contains the bitstr...
void ff_mpeg_draw_horiz_band(MpegEncContext *s, int y, int h)
const uint8_t ff_alternate_vertical_scan[64]
static const uint32_t ptype2mb_type[7]
enum OutputFormat out_format
output format
static av_cold int end(AVCodecContext *avctx)
const float ff_mpeg1_aspect[16]
#define CONFIG_MPEG1_VDPAU_DECODER
Multithreading support functions.
#define CODEC_CAP_HWACCEL_VDPAU
Codec can export data for HW decoding (VDPAU).
static int load_matrix(MpegEncContext *s, uint16_t matrix0[64], uint16_t matrix1[64], int intra)
const char * name
Name of the codec implementation.
int av_frame_ref(AVFrame *dst, AVFrame *src)
Setup a new reference to the data described by a given frame.
static enum AVPixelFormat mpeg_get_pixelformat(AVCodecContext *avctx)
static int mpeg1_fast_decode_block_inter(MpegEncContext *s, int16_t *block, int n)
Note: this function can read out of range and crash for corrupt streams.
Picture current_picture
copy of the current picture structure.
#define CODEC_CAP_DR1
Codec uses get_buffer() for allocating buffers and supports custom allocators.
#define FF_PROFILE_MPEG2_SS
void ff_xvmc_init_block(MpegEncContext *s)
Initialize the block field of the MpegEncContext pointer passed as parameter after making sure that t...
AVRational av_mul_q(AVRational b, AVRational c) av_const
Multiply two rationals.
static int get_bits_count(const GetBitContext *s)
void ff_xvmc_pack_pblocks(MpegEncContext *s, int cbp)
Fill individual block pointers, so there are no gaps in the data_block array in case not all blocks i...
uint8_t idct_permutation[64]
idct input permutation.
int flags2
AVCodecContext.flags2.
#define SLICE_FLAG_CODED_ORDER
draw_horiz_band() is called in coded order instead of display
int mb_height
number of MBs horizontally & vertically
int lowres
low resolution decoding, 1-> 1/2 size, 2->1/4 size
void ff_MPV_frame_end(MpegEncContext *s)
int codec_tag
internal codec_tag upper case converted from avctx codec_tag
#define FF_PROFILE_MPEG2_SNR_SCALABLE
enum AVChromaLocation chroma_sample_location
This defines the location of chroma samples.
const uint8_t * avpriv_find_start_code(const uint8_t *p, const uint8_t *end, uint32_t *state)
static void setup_hwaccel_for_pixfmt(AVCodecContext *avctx)
static int get_bits_left(GetBitContext *gb)
int slice_context_count
number of used thread_contexts
#define CODEC_FLAG_TRUNCATED
#define UPDATE_CACHE(name, gb)
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
int has_b_frames
Size of the frame reordering buffer in the decoder.
int last_dc[3]
last DC values for MPEG1
#define CONFIG_MPEG_VDPAU_DECODER
uint8_t pi<< 24) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_U8, uint8_t,(*(constuint8_t *) pi-0x80)*(1.0f/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_U8, uint8_t,(*(constuint8_t *) pi-0x80)*(1.0/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S16, int16_t,(*(constint16_t *) pi >>8)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S16, int16_t,*(constint16_t *) pi *(1.0f/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S16, int16_t,*(constint16_t *) pi *(1.0/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S32, int32_t,(*(constint32_t *) pi >>24)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S32, int32_t,*(constint32_t *) pi *(1.0f/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S32, int32_t,*(constint32_t *) pi *(1.0/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_FLT, float, av_clip_uint8(lrintf(*(constfloat *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_FLT, float, av_clip_int16(lrintf(*(constfloat *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_FLT, float, av_clipl_int32(llrintf(*(constfloat *) pi *(1U<< 31)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_DBL, double, av_clip_uint8(lrint(*(constdouble *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_DBL, double, av_clip_int16(lrint(*(constdouble *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_DBL, double, av_clipl_int32(llrint(*(constdouble *) pi *(1U<< 31))))#defineSET_CONV_FUNC_GROUP(ofmt, ifmt) staticvoidset_generic_function(AudioConvert *ac){}voidff_audio_convert_free(AudioConvert **ac){return;ff_dither_free(&(*ac) ->dc);av_freep(ac);}AudioConvert *ff_audio_convert_alloc(AVAudioResampleContext *avr, enumAVSampleFormatout_fmt, enumAVSampleFormatin_fmt, intchannels, intsample_rate, intapply_map){AudioConvert *ac;intin_planar, out_planar;ac=av_mallocz(sizeof(*ac));returnNULL;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);returnNULL;}returnac;}in_planar=av_sample_fmt_is_planar(in_fmt);out_planar=av_sample_fmt_is_planar(out_fmt);if(in_planar==out_planar){ac->func_type=CONV_FUNC_TYPE_FLAT;ac->planes=in_planar?ac->channels:1;}elseif(in_planar) ac->func_type=CONV_FUNC_TYPE_INTERLEAVE;elseac->func_type=CONV_FUNC_TYPE_DEINTERLEAVE;set_generic_function(ac);ff_audio_convert_init_arm(ac);ff_audio_convert_init_x86(ac);returnac;}intff_audio_convert(AudioConvert *ac, AudioData *out, AudioData *in){intuse_generic=1;intlen=in->nb_samples;intp;if(ac->dc){av_dlog(ac->avr,"%dsamples-audio_convert:%sto%s(dithered)\n", len, av_get_sample_fmt_name(ac->in_fmt), av_get_sample_fmt_name(ac->out_fmt));returnff_convert_dither(ac-> dc
void ff_er_add_slice(ERContext *s, int startx, int starty, int endx, int endy, int status)
Add a slice.
int mb_skipped
MUST BE SET only during DECODING.
#define CODEC_CAP_DELAY
Encoder or decoder requires flushing with NULL input at the end in order to give the complete and cor...
int ff_combine_frame(ParseContext *pc, int next, const uint8_t **buf, int *buf_size)
Combine the (truncated) bitstream to a complete frame.
static void mpeg_decode_sequence_extension(Mpeg1Context *s1)
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
#define FF_THREAD_SLICE
Decode more than one part of a single frame at once.
static int mpeg1_decode_block_inter(MpegEncContext *s, int16_t *block, int n)
int active_thread_type
Which multithreading methods are in use by the codec.
AVCodec ff_mpegvideo_decoder
AVRational av_div_q(AVRational b, AVRational c) av_const
Divide one rational by another.
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
static int get_qscale(MpegEncContext *s)
int rc_max_rate
maximum bitrate
#define FF_PROFILE_MPEG2_HIGH
XVideo Motion Acceleration via common packet passing.
#define FF_DEBUG_STARTCODE
static int mpeg_decode_motion(MpegEncContext *s, int fcode, int pred)
int width
width and height in 1/16 pel
int low_delay
no reordering needed / has no b-frames
static void mpeg_decode_user_data(AVCodecContext *avctx, const uint8_t *p, int buf_size)
#define FF_PROFILE_RESERVED
#define CLOSE_READER(name, gb)
static int decode_dc(GetBitContext *gb, int component)
Libavcodec external API header.
AVPixelFormat
Pixel format.
#define DECODE_SLICE_ERROR
#define CODEC_FLAG_LOW_DELAY
Force low delay.
#define GET_RL_VLC(level, run, name, gb, table, bits,max_depth, need_update)
void ff_mpeg_flush(AVCodecContext *avctx)
#define SKIP_BITS(name, gb, num)
#define ONLY_IF_THREADS_ENABLED(x)
Define a function with only the non-default version specified.
int resync_mb_x
x position of last resync marker
int rc_buffer_size
decoder bitstream buffer size
static int update_thread_context(AVCodecContext *dst, const AVCodecContext *src)
int av_reduce(int *dst_num, int *dst_den, int64_t num, int64_t den, int64_t max)
Reduce a fraction.
#define MB_PTYPE_VLC_BITS
#define CODEC_FLAG2_SHOW_ALL
Show all frames before the first keyframe.
common internal API header
int dtg_active_format
DTG active format information (additional aspect ratio information only used in DVB MPEG-2 transport ...
static int mpeg_field_start(MpegEncContext *s, const uint8_t *buf, int buf_size)
static const uint8_t non_linear_qscale[32]
static int mpeg2_decode_block_non_intra(MpegEncContext *s, int16_t *block, int n)
int bit_rate
the average bitrate
int ff_mpv_export_qp_table(MpegEncContext *s, AVFrame *f, Picture *p, int qp_type)
int64_t timecode_frame_start
GOP timecode frame start number.
void ff_mpeg_er_frame_start(MpegEncContext *s)
AVRational av_d2q(double d, int max) av_const
Convert a double precision floating point number to a rational.
enum AVPictureType pict_type
Picture type of the frame.
int err_recognition
Error recognition; may misdetect some more or less valid parts as errors.
#define CODEC_CAP_DRAW_HORIZ_BAND
Decoder can use draw_horiz_band callback.
#define MB_BTYPE_VLC_BITS
static int vcr2_init_sequence(AVCodecContext *avctx)
uint8_t * mbskip_table
used to avoid copy if macroblock skipped (for black regions for example) and used for b-frame encodin...
void(* clear_blocks)(int16_t *blocks)
int idct_algo
IDCT algorithm, see FF_IDCT_* below.
#define MB_TYPE_INTERLACED
int16_t(*[2] motion_val)[2]
Picture * current_picture_ptr
pointer to the current picture
enum AVColorPrimaries color_primaries
Chromaticity coordinates of the source primaries.
static unsigned int show_bits(GetBitContext *s, int n)
Show 1-25 bits.
char * av_timecode_make_mpeg_tc_string(char *buf, uint32_t tc25bit)
Get the timecode string from the 25-bit timecode format (MPEG GOP format).
#define LAST_SKIP_BITS(name, gb, num)
static av_cold int mpeg_decode_end(AVCodecContext *avctx)
static av_always_inline int get_vlc2(GetBitContext *s, VLC_TYPE(*table)[2], int bits, int max_depth)
Parse a vlc code.
static void mpeg_decode_quant_matrix_extension(MpegEncContext *s)
int16_t(*[12] pblocks)[64]
int block_last_index[12]
last non zero coefficient in block
int ticks_per_frame
For some codecs, the time base is closer to the field rate than the frame rate.
#define FF_PROFILE_UNKNOWN
int mpeg_enc_ctx_allocated
int ff_MPV_frame_start(MpegEncContext *s, AVCodecContext *avctx)
generic function for encode/decode called after coding/decoding the header and before a frame is code...
#define AV_EF_AGGRESSIVE
consider things that a sane encoder should not do as an error
int ff_mpeg_update_thread_context(AVCodecContext *dst, const AVCodecContext *src)
preferred ID for MPEG-1/2 video decoding
RL_VLC_ELEM * rl_vlc[32]
decoding only
#define SHOW_UBITS(name, gb, num)
int thread_count
thread count is used to decide how many independent tasks should be passed to execute() ...
static int mpeg1_decode_sequence(AVCodecContext *avctx, const uint8_t *buf, int buf_size)
int xvmc_acceleration
XVideo Motion Acceleration.
static const float pred[4]
int first_field
is 1 for the first field of a field picture 0 otherwise
#define MV_TYPE_16X16
1 vector for the whole mb
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
static int mpeg2_decode_block_intra(MpegEncContext *s, int16_t *block, int n)
uint16_t inter_matrix[64]
static enum AVPixelFormat mpeg2_hwaccel_pixfmt_list_420[]
int concealment_motion_vectors
struct MpegEncContext * thread_context[MAX_THREADS]
AVRational frame_rate_ext
MPEG-2 specific framerate modificator.
static int mpeg2_fast_decode_block_intra(MpegEncContext *s, int16_t *block, int n)
Note: this function can read out of range and crash for corrupt streams.
main external API structure.
static void close(AVCodecParserContext *s)
#define FF_THREAD_FRAME
Decode more than one frame at once.
#define AV_EF_EXPLODE
abort decoding on minor error detection
ScanTable intra_scantable
#define AV_TIMECODE_STR_SIZE
#define AV_EF_BITSTREAM
detect bitstream specification deviations
int height
picture size. must be a multiple of 16
unsigned int codec_tag
fourcc (LSB first, so "ABCD" -> ('D'<<24) + ('C'<<16) + ('B'<<8) + 'A').
#define OPEN_READER(name, gb)
av_cold void ff_init_scantable(uint8_t *permutation, ScanTable *st, const uint8_t *src_scantable)
#define MV_TYPE_16X8
2 vectors, one per 16x8 block
static int mpeg_decode_slice(MpegEncContext *s, int mb_y, const uint8_t **buf, int buf_size)
Decode a slice.
MPEG-2 HW decoding with VDPAU, data[0] contains a vdpau_render_state struct which contains the bitstr...
void ff_print_debug_info(MpegEncContext *s, Picture *p, AVFrame *pict)
static unsigned int get_bits1(GetBitContext *s)
static void exchange_uv(MpegEncContext *s)
BYTE int const BYTE int int int height
static void skip_bits1(GetBitContext *s)
int slice_flags
slice flags
void ff_MPV_decode_mb(MpegEncContext *s, int16_t block[12][64])
static void skip_bits(GetBitContext *s, int n)
int closed_gop
MPEG1/2 GOP is closed.
unsigned int avpriv_toupper4(unsigned int x)
enum AVColorSpace colorspace
YUV colorspace type.
rational number numerator/denominator
enum AVColorTransferCharacteristic color_trc
Color Transfer Characteristic.
static int init_get_bits(GetBitContext *s, const uint8_t *buffer, int bit_size)
Initialize GetBitContext.
#define GET_CACHE(name, gb)
const uint16_t ff_mpeg1_default_intra_matrix[256]
int ff_mpeg1_find_frame_end(ParseContext *pc, const uint8_t *buf, int buf_size, AVCodecParserContext *s)
Find the end of the current frame in the bitstream.
AVHWAccel * ff_find_hwaccel(enum AVCodecID codec_id, enum AVPixelFormat pix_fmt)
Return the hardware accelerated codec for codec codec_id and pixel format pix_fmt.
static int mpeg1_decode_block_intra(MpegEncContext *s, int16_t *block, int n)
planar YUV 4:4:4, 24bpp, (1 Cr & Cb sample per 1x1 Y samples)
DSPContext dsp
pointers for accelerated dsp functions
int linesize[AV_NUM_DATA_POINTERS]
For video, size in bytes of each picture line.
static int uses_vdpau(AVCodecContext *avctx)
int ff_mpeg1_decode_block_intra(MpegEncContext *s, int16_t *block, int n)
static int mpeg_decode_frame(AVCodecContext *avctx, void *data, int *got_output, AVPacket *avpkt)
static int decode_chunks(AVCodecContext *avctx, AVFrame *picture, int *got_output, const uint8_t *buf, int buf_size)
int pict_type
AV_PICTURE_TYPE_I, AV_PICTURE_TYPE_P, AV_PICTURE_TYPE_B, ...
int bit_rate
wanted bit rate
static const uint8_t start_code[]
av_cold void ff_mpeg12_common_init(MpegEncContext *s)
static av_const int sign_extend(int val, unsigned bits)
int skip_bottom
Number of macroblock rows at the bottom which are skipped.
#define FF_DEBUG_PICT_INFO
int mv[2][4][2]
motion vectors for a macroblock first coordinate : 0 = forward 1 = backward second " : depend...
int b8_stride
2*mb_width+1 used for some 8x8 block arrays to allow simple addressing
HW decoding through VA API, Picture.data[3] contains a vaapi_render_state struct which contains the b...
Picture * next_picture_ptr
pointer to the next picture (for bidir pred)
struct AVCodecContext * avctx
#define SHOW_SBITS(name, gb, num)
void ff_vdpau_mpeg_picture_complete(MpegEncContext *s, const uint8_t *buf, int buf_size, int slice_count)
discard all non reference
const AVRational ff_mpeg2_aspect[16]
static enum AVPixelFormat mpeg1_hwaccel_pixfmt_list_420[]
#define CODEC_CAP_SLICE_THREADS
Codec supports slice-based (or partition-based) multithreading.
common internal api header.
const uint8_t ff_zigzag_direct[64]
int mb_stride
mb_width+1 used for some arrays to allow simple addressing of left & top MBs without sig11 ...
AVCodec ff_mpeg2video_decoder
static int mpeg_decode_mb(MpegEncContext *s, int16_t block[12][64])
#define FF_PROFILE_MPEG2_SIMPLE
int16_t position[3][2]
position of the top left corner in 1/16 pel for up to 3 fields/frames
const uint8_t * buffer_end
static void flush(AVCodecContext *avctx)
#define SLICE_FLAG_ALLOW_FIELD
allow draw_horiz_band() with field slices (MPEG2 field pics)
Picture * last_picture_ptr
pointer to the previous picture.
static int mpeg1_decode_picture(AVCodecContext *avctx, const uint8_t *buf, int buf_size)
int ff_update_duplicate_context(MpegEncContext *dst, MpegEncContext *src)
static int slice_end(AVCodecContext *avctx, AVFrame *pict)
Handle slice ends.
static int mpeg_decode_postinit(AVCodecContext *avctx)
#define AVERROR_INVALIDDATA
int(* execute)(struct AVCodecContext *c, int(*func)(struct AVCodecContext *c2, void *arg), void *arg2, int *ret, int count, int size)
The codec may call this to execute several independent things.
void ff_MPV_common_end(MpegEncContext *s)
#define MV_TYPE_DMV
2 vectors, special mpeg2 Dual Prime Vectors
struct AVHWAccel * hwaccel
Hardware accelerator in use.
int resync_mb_y
y position of last resync marker
int16_t(* block)[64]
points to one of the following blocks
ParseContext parse_context
#define FF_QSCALE_TYPE_MPEG2
VLC_TYPE(* table)[2]
code, bits
int key_frame
1 -> keyframe, 0-> not
static const uint8_t * align_get_bits(GetBitContext *s)
MpegEncContext mpeg_enc_ctx
HW acceleration through VDPAU, Picture.data[3] contains a VdpVideoSurface.
int flags
AVCodecContext.flags (HQ, MV4, ...)
uint16_t intra_matrix[64]
matrix transmitted in the bitstream
the normal 219*2^(n-8) "MPEG" YUV ranges
ScanTable inter_scantable
if inter == intra then intra should be used to reduce tha cache usage
#define PICTURE_START_CODE
static int decode(AVCodecContext *avctx, void *data, int *got_frame, AVPacket *avpkt)
#define av_assert0(cond)
assert() equivalent, that is always enabled.
void ff_thread_finish_setup(AVCodecContext *avctx)
If the codec defines update_thread_context(), call this when they are ready for the next thread to st...
int(* decode_slice)(AVCodecContext *avctx, const uint8_t *buf, uint32_t buf_size)
Callback for each slice.
static int slice_decode_thread(AVCodecContext *c, void *arg)
#define AV_EF_COMPLIANT
consider all spec non compliancies as errors
int(* end_frame)(AVCodecContext *avctx)
Called at the end of each frame or field picture.
This structure stores compressed data.
const AVRational ff_mpeg12_frame_rate_tab[16]
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
AVFrameSideData * av_frame_new_side_data(AVFrame *frame, enum AVFrameSideDataType type, int size)
Add a new side data to a frame.
static void mpeg_decode_picture_display_extension(Mpeg1Context *s1)
void ff_MPV_decode_defaults(MpegEncContext *s)
Set the given MpegEncContext to defaults for decoding.
#define av_assert2(cond)
assert() equivalent, that does lie in speed critical code.
AVPanScan pan_scan
some temporary storage for the panscan