28 #define UNCHECKED_BITSTREAM_READER 1
30 #include "libavutil/cpu.h"
160 if (pos + 10 > buf_size)
189 const int qscale = s->
qscale;
261 "Slice mismatch at MB: %d\n", xy);
304 if (bits_left == 0) {
306 }
else if (bits_left != 1) {
308 v |= 0x7F >> (7 - (bits_count & 7));
310 if (v == 0x7F && bits_left <= 8)
343 max_extra += 256 * 256 * 256 * 64;
345 if (left > max_extra)
347 "discarding %d junk bits at end, next would be %X\n",
359 "slice end not reached but screenspace end (%d left %06X, score= %d)\n",
372 int buf_size = avpkt->
size;
405 "this codec does not support truncated bitstreams\n");
417 for(i=0; i < buf_size-3; i++) {
418 if (buf[i]==0 && buf[i+1]==0 && buf[i+2]==1) {
419 if (buf[i+3]==0xB0) {
541 #define SET_QPEL_FUNC(postfix1, postfix2) \
542 s->dsp.put_ ## postfix1 = ff_put_ ## postfix2; \
543 s->dsp.put_no_rnd_ ## postfix1 = ff_put_no_rnd_ ## postfix2; \
544 s->dsp.avg_ ## postfix1 = ff_avg_ ## postfix2;
603 "bugs: %X lavc_build:%d xvid_build:%d divx_version:%d divx_build:%d %s\n",
708 int prev_x = s->
mb_x, prev_y = s->
mb_y;
743 int startcode_found = 0;
745 if (buf_size - current_pos > 7) {
747 for (i = current_pos; i < buf_size - 4; i++)
751 buf[i + 3] == 0xB6) {
752 startcode_found = !(buf[i + 4] & 0x40);
757 if (startcode_found) {
760 buf_size - current_pos +
765 buf_size - current_pos);
792 for (p=0; p<3; p++) {
796 for (y=0; y<(h>>1); y++)
799 pict->
data[p][x + y*linesize],
800 pict->
data[p][x + (h-1-y)*linesize]);
int bitstream_buffer_size
#define FF_BUG_AUTODETECT
autodetection
discard all frames except keyframes
void ff_init_block_index(MpegEncContext *s)
unsigned int stream_codec_tag
fourcc from the AVI stream header (LSB first, so "ABCD" -> ('D'<<24) + ('C'<<16) + ('B'<<8) + ...
int(* start_frame)(AVCodecContext *avctx, const uint8_t *buf, uint32_t buf_size)
Called at the beginning of each frame or field picture.
This structure describes decoded (raw) audio or video data.
int vol_control_parameters
does the stream contain the low_delay flag, used to workaround buggy encoders
int coded_width
Bitstream width / height, may be different from width/height e.g.
av_cold int ff_dct_common_init(MpegEncContext *s)
av_cold int ff_MPV_common_init(MpegEncContext *s)
init common structure for both encoder and decoder.
#define SLICE_NOEND
no end marker or error found but mb count exceeded
#define AV_LOG_WARNING
Something somehow does not look correct.
void ff_MPV_report_decode_progress(MpegEncContext *s)
static av_cold int init(AVCodecContext *avctx)
static int decode_slice(MpegEncContext *s)
#define CODEC_CAP_TRUNCATED
void ff_er_frame_end(ERContext *s)
int msmpeg4_version
0=not msmpeg4, 1=mp41, 2=mp42, 3=mp43/divx3 4=wmv1/7 5=wmv2/8
void avcodec_set_dimensions(AVCodecContext *s, int width, int height)
uint8_t * bitstream_buffer
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.
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)
int padding_bug_score
used to detect the VERY common padding bug in MPEG4
int mb_num
number of MBs of a picture
uint8_t * extradata
some codecs need / can use extradata like Huffman tables.
int ff_h263_decode_mb(MpegEncContext *s, int16_t block[6][64])
#define FF_QSCALE_TYPE_MPEG1
int ff_mpeg4_decode_partitions(MpegEncContext *s)
Decode the first and second partition.
enum AVDiscard skip_frame
Skip decoding for selected frames.
void ff_mpeg4_clean_buffers(MpegEncContext *s)
void av_fast_malloc(void *ptr, unsigned int *size, size_t min_size)
Allocate a buffer, reusing the given one if large enough.
void ff_mpeg_draw_horiz_band(MpegEncContext *s, int y, int h)
int ff_MPV_common_frame_size_change(MpegEncContext *s)
void ff_h263_decode_init_vlc(void)
enum OutputFormat out_format
output format
Multithreading support functions.
#define CODEC_CAP_HWACCEL_VDPAU
Codec can export data for HW decoding (VDPAU).
qpel_mc_func(* qpel_put)[16]
const char * name
Name of the codec implementation.
int no_rounding
apply no rounding to motion compensation (MPEG4, msmpeg4, ...) for b-frames rounding mode is always 0...
int resync_marker
could this stream contain resync markers
int av_frame_ref(AVFrame *dst, AVFrame *src)
Setup a new reference to the data described by a given frame.
int ff_intel_h263_decode_picture_header(MpegEncContext *s)
Picture current_picture
copy of the current picture structure.
GetBitContext last_resync_gb
used to search for the next resync marker
#define FF_CEIL_RSHIFT(a, b)
#define CODEC_CAP_DR1
Codec uses get_buffer() for allocating buffers and supports custom allocators.
static int get_bits_count(const GetBitContext *s)
int flags2
AVCodecContext.flags2.
int mb_height
number of MBs horizontally & vertically
int lowres
low resolution decoding, 1-> 1/2 size, 2->1/4 size
#define CONFIG_H263I_DECODER
void ff_MPV_frame_end(MpegEncContext *s)
int codec_tag
internal codec_tag upper case converted from avctx codec_tag
#define FFSWAP(type, a, b)
int ff_wmv2_decode_picture_header(MpegEncContext *s)
enum AVChromaLocation chroma_sample_location
This defines the location of chroma samples.
int av_get_cpu_flags(void)
Return the flags which specify extensions supported by the CPU.
static void ff_update_block_index(MpegEncContext *s)
qpel_mc_func put_qpel_pixels_tab[2][16]
void ff_set_qscale(MpegEncContext *s, int qscale)
set qscale and update qscale dependent variables.
#define CONFIG_H263P_DECODER
static int get_bits_left(GetBitContext *gb)
#define CODEC_FLAG_TRUNCATED
#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 stream_codec_tag
internal stream_codec_tag upper case converted from avctx stream_codec_tag
int last_dc[3]
last DC values for MPEG1
void ff_er_add_slice(ERContext *s, int startx, int starty, int endx, int endy, int status)
Add a slice.
#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.
int partitioned_frame
is current frame partitioned
qpel_mc_func avg_qpel_pixels_tab[2][16]
int unrestricted_mv
mv can point outside of the coded picture
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
int capabilities
Codec capabilities.
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
int ff_wmv2_decode_secondary_picture_header(MpegEncContext *s)
#define AV_EF_BUFFER
detect improper bitstream length
int low_delay
no reordering needed / has no b-frames
int(* decode_mb)(struct MpegEncContext *s, int16_t block[6][64])
Libavcodec external API header.
AVPixelFormat
Pixel format.
int ff_flv_decode_picture_header(MpegEncContext *s)
void ff_mpeg_flush(AVCodecContext *avctx)
int resync_mb_x
x position of last resync marker
uint8_t * error_status_table
int ff_h263_decode_init(AVCodecContext *avctx)
#define FF_INPUT_BUFFER_PADDING_SIZE
Required number of additionally allocated bytes at the end of the input bitstream for decoding...
int av_frame_make_writable(AVFrame *frame)
Ensure that the frame data is writable, avoiding data copy if possible.
void ff_h263_loop_filter(MpegEncContext *s)
int ff_h263_decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPacket *avpkt)
int ff_mpv_export_qp_table(MpegEncContext *s, AVFrame *f, Picture *p, int qp_type)
void ff_mpeg_er_frame_start(MpegEncContext *s)
enum AVPictureType pict_type
Picture type of the frame.
#define CONFIG_MPEG4_DECODER
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.
int ff_h263_get_gob_height(MpegEncContext *s)
Get the GOB height based on picture height.
static int get_consumed_bytes(MpegEncContext *s, int buf_size)
Return the number of bytes consumed for building the current frame.
int next_p_frame_damaged
set if the next p frame is damaged, to avoid showing trashed b frames
int idct_algo
IDCT algorithm, see FF_IDCT_* below.
Picture * current_picture_ptr
pointer to the current picture
enum AVPixelFormat ff_h263_hwaccel_pixfmt_list_420[]
unsigned int allocated_bitstream_buffer_size
static unsigned int show_bits(GetBitContext *s, int n)
Show 1-25 bits.
int ff_msmpeg4_decode_ext_header(MpegEncContext *s, int buf_size)
#define SET_QPEL_FUNC(postfix1, postfix2)
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
static void flush(AVCodecContext *avctx)
int format
format of the frame, -1 if unknown or unset Values correspond to enum AVPixelFormat for video frames...
#define MV_TYPE_16X16
1 vector for the whole mb
int first_slice_line
used in mpeg4 too to handle resync markers
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
#define AV_CPU_FLAG_MMX
standard MMX
void ff_h263_update_motion_val(MpegEncContext *s)
int h263_flv
use flv h263 header
#define FF_BUG_NO_PADDING
static int init_get_bits8(GetBitContext *s, const uint8_t *buffer, int byte_size)
Initialize GetBitContext.
main external API structure.
static void close(AVCodecParserContext *s)
#define AV_EF_EXPLODE
abort decoding on minor error detection
int height
picture size. must be a multiple of 16
void ff_print_debug_info(MpegEncContext *s, Picture *p, AVFrame *pict)
#define SLICE_END
end marker found
Picture * picture
main picture buffer
int data_partitioning
data partitioning flag from header
#define CONFIG_H263_DECODER
void ff_MPV_decode_mb(MpegEncContext *s, int16_t block[12][64])
enum AVPixelFormat(* get_format)(struct AVCodecContext *s, const enum AVPixelFormat *fmt)
callback to negotiate the pixelFormat
#define CONFIG_MPEG4_VDPAU_DECODER
#define FF_BUG_XVID_ILACE
int slice_height
in macroblocks
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.
#define CONFIG_FLV_DECODER
DSPContext dsp
pointers for accelerated dsp functions
int linesize[AV_NUM_DATA_POINTERS]
For video, size in bytes of each picture line.
int ff_h263_decode_picture_header(MpegEncContext *s)
int pict_type
AV_PICTURE_TYPE_I, AV_PICTURE_TYPE_P, AV_PICTURE_TYPE_B, ...
#define av_assert1(cond)
assert() equivalent, that does not lie in speed critical code.
int h263_pred
use mpeg4/h263 ac/dc predictions
int ff_h263_resync(MpegEncContext *s)
Decode the group of blocks / video packet header.
qpel_mc_func(* qpel_avg)[16]
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 FF_BUG_QPEL_CHROMA
discard all non reference
common internal api header.
int mb_stride
mb_width+1 used for some arrays to allow simple addressing of left & top MBs without sig11 ...
const uint8_t * buffer_end
Picture * last_picture_ptr
pointer to the previous picture.
int workaround_bugs
Work around bugs in encoders which sometimes cannot be detected automatically.
#define FF_BUG_DIRECT_BLOCKSIZE
enum AVPixelFormat * pix_fmts
array of supported pixel formats, or NULL if unknown, array is terminated by -1
int ff_h263_decode_end(AVCodecContext *avctx)
#define AVERROR_INVALIDDATA
void ff_MPV_common_end(MpegEncContext *s)
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
void ff_vdpau_mpeg4_decode_picture(MpegEncContext *s, const uint8_t *buf, int buf_size)
int key_frame
1 -> keyframe, 0-> not
#define CONFIG_WMV2_DECODER
HW acceleration through VDPAU, Picture.data[3] contains a VdpVideoSurface.
int flags
AVCodecContext.flags (HQ, MV4, ...)
int workaround_bugs
workaround bugs in encoders which cannot be detected automatically
#define FRAME_SKIPPED
return value for header parsers if frame is not coded
qpel_mc_func put_no_rnd_qpel_pixels_tab[2][16]
static int decode(AVCodecContext *avctx, void *data, int *got_frame, AVPacket *avpkt)
int ff_mpeg4_decode_picture_header(MpegEncContext *s, GetBitContext *gb)
Decode mpeg4 headers.
int ff_msmpeg4_decode_picture_header(MpegEncContext *s)
int ff_mpeg4_find_frame_end(ParseContext *pc, const uint8_t *buf, int buf_size)
Find the end of the current frame in the bitstream.
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...
#define FF_BUG_QPEL_CHROMA2
#define CONFIG_MSMPEG4_DECODER
int(* decode_slice)(AVCodecContext *avctx, const uint8_t *buf, uint32_t buf_size)
Callback for each slice.
int ff_find_unused_picture(MpegEncContext *s, int shared)
int ff_h263_find_frame_end(ParseContext *pc, const uint8_t *buf, int buf_size)
int(* end_frame)(AVCodecContext *avctx)
Called at the end of each frame or field picture.
#define FF_BUG_HPEL_CHROMA
This structure stores compressed data.
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
void ff_MPV_decode_defaults(MpegEncContext *s)
Set the given MpegEncContext to defaults for decoding.