45 #define RV_GET_MAJOR_VER(x) ((x) >> 28) 46 #define RV_GET_MINOR_VER(x) (((x) >> 20) & 0xFF) 47 #define RV_GET_MICRO_VER(x) (((x) >> 12) & 0xFF) 49 #define MAX_VLC_ENTRIES 1023 // Note: Does not include the skip entries. 63 { 0, 0 }, { 1, 0 }, { 255, 0 }, { 3, 1 }, { 254, 1 },
64 { 7, 3 }, { 252, 3 }, { 15, 7 }, { 248, 7 }, { 31, 15 },
65 { 240, 15 }, { 63, 31 }, { 224, 31 }, { 127, 63 }, { 192, 63 },
66 { 255, 127 }, { 128, 127 }, { 127, 255 }, { 128, 255 },
72 1, 0, 2, 4, 8, 16, 32, 0, 64, 0, 128, 0, 256, 0, 512,
76 1, 2, 4, 0, 8, 0, 16, 0, 32, 0, 64, 0, 128, 0, 256,
100 int mb_count, pb_frame, marker, mb_xy;
141 if (
show_bits(&s->
gb, 12) == 0 || (mb_xy && mb_xy < s->mb_num)) {
160 int seq, mb_pos,
i,
ret;
213 int rpr_bits =
av_log2(rpr_max) + 1;
232 "attempting to change resolution to %dx%d\n", new_w, new_h);
240 if (2 * (int64_t)new_w * s->
height == (int64_t)new_h * s->
width)
242 if ((int64_t)new_w * s->
height == 2 * (int64_t)new_h * s->
width)
264 seq |= s->
time & ~0x7FFF;
265 if (seq - s->
time > 0x4000)
267 if (seq - s->
time < -0x4000)
270 if (seq != s->
time) {
283 "messed up order, possible from seeking? skipping current B-frame\n");
284 #define ERROR_SKIP_FRAME -123 305 "num:%5d x:%2d y:%2d type:%d qscale:%2d rnd:%d\n",
316 const uint8_t sym_rl[][2],
int sym_rl_elems)
320 unsigned nb_syms = 0, nb_lens = 0;
322 for (
unsigned i = 0;
i < sym_rl_elems;
i++) {
323 unsigned cur_sym = sym_rl[
i][0];
324 for (
unsigned tmp = nb_syms + sym_rl[
i][1]; nb_syms <=
tmp; nb_syms++)
325 syms[nb_syms] = 0xFF & cur_sym--;
328 for (
unsigned i = 0;
i < 15;
i++)
329 for (
unsigned tmp = nb_lens + len_count[
i]; nb_lens <
tmp; nb_lens++)
330 lens[nb_lens] =
i + 2;
350 rv_dc_chrom.
table = &table[1472];
367 int major_ver, minor_ver, micro_ver,
ret;
397 s->
obmc = micro_ver == 2;
400 if (minor_ver >= 2) {
439 int buf_size,
int buf_size2,
int whole_size)
443 int mb_count, mb_pos,
left, start_mb_x, active_bits_size,
ret;
445 active_bits_size = buf_size * 8;
464 if (mb_count > left) {
469 if (whole_size < s->mb_width * s->
mb_height / 8)
500 start_mb_x = s->
mb_x;
549 active_bits_size = buf_size2 * 8;
551 8 * buf_size, active_bits_size);
580 return active_bits_size;
595 int buf_size = avpkt->
size;
610 slice_count = (*buf++) + 1;
613 if (!slice_count || buf_size <= 8 * slice_count) {
619 slices_hdr = buf + 4;
620 buf += 8 * slice_count;
621 buf_size -= 8 * slice_count;
625 for (i = 0; i < slice_count; i++) {
629 if (offset >= buf_size)
632 if (i + 1 == slice_count)
637 if (i + 2 >= slice_count)
638 size2 = buf_size -
offset;
642 if (size <= 0 || size2 <= 0 ||
643 offset +
FFMAX(size, size2) > buf_size)
#define FF_CODEC_CAP_INIT_CLEANUP
The codec allows calling the close function for deallocation even if the init function returned a fai...
int rv10_first_dc_coded[3]
void ff_init_block_index(MpegEncContext *s)
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
This structure describes decoded (raw) audio or video data.
static int get_slice_offset(AVCodecContext *avctx, const uint8_t *buf, int n)
ptrdiff_t const GLvoid * data
static void flush(AVCodecContext *avctx)
const uint8_t * y_dc_scale_table
qscale -> y_dc_scale table
int coded_width
Bitstream width / height, may be different from width/height e.g.
static unsigned int get_bits(GetBitContext *s, int n)
Read 1-25 bits.
int ff_set_dimensions(AVCodecContext *s, int width, int height)
Check that the provided frame dimensions are valid and set them on the codec context.
static av_cold int init(AVCodecContext *avctx)
#define avpriv_request_sample(...)
void ff_er_frame_end(ERContext *s)
av_cold void ff_h263dsp_init(H263DSPContext *ctx)
int obmc
overlapped block motion compensation
AVRational sample_aspect_ratio
sample aspect ratio (0 if unknown) That is the width of a pixel divided by the height of the pixel...
enum AVPixelFormat pix_fmt
Pixel format, see AV_PIX_FMT_xxx.
#define FF_ARRAY_ELEMS(a)
static int rv10_decode_picture_header(MpegEncContext *s)
int h263_aic
Advanced INTRA Coding (AIC)
static void decode(AVCodecContext *dec_ctx, AVPacket *pkt, AVFrame *frame, FILE *outfile)
int ff_h263_decode_mb(MpegEncContext *s, int16_t block[6][64])
#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_assert0(cond)
assert() equivalent, that is always enabled.
int mb_num_left
number of MBs left in this video packet (for partitioned Slices only)
int64_t time
time of current frame
const uint8_t ff_mpeg1_dc_scale_table[128]
void ff_h263_decode_init_vlc(void)
enum OutputFormat out_format
output format
#define FF_DEBUG_PICT_INFO
it s the only field you need to keep assuming you have a context There is some magic you don t need to care about around this just let it vf offset
#define RV_GET_MICRO_VER(x)
int av_frame_ref(AVFrame *dst, const AVFrame *src)
Set up a new reference to the data described by the source frame.
int ff_rv_decode_dc(MpegEncContext *s, int n)
uint8_t * extradata
some codecs need / can use extradata like Huffman tables.
int no_rounding
apply no rounding to motion compensation (MPEG-4, msmpeg4, ...) for B-frames rounding mode is always ...
uint64_t_TMPL AV_WL64 unsigned int_TMPL AV_WL32 unsigned int_TMPL AV_WL24 unsigned int_TMPL AV_WL16 uint64_t_TMPL AV_WB64 unsigned int_TMPL AV_RB32
static int get_bits_count(const GetBitContext *s)
int ff_h263_decode_mba(MpegEncContext *s)
uint16_t pp_time
time distance between the last 2 p,s,i frames
av_cold void ff_mpv_idct_init(MpegEncContext *s)
int mb_height
number of MBs horizontally & vertically
int lowres
low resolution decoding, 1-> 1/2 size, 2->1/4 size
static void ff_update_block_index(MpegEncContext *s)
static const uint16_t table[]
void ff_set_qscale(MpegEncContext *s, int qscale)
set qscale and update qscale dependent variables.
static int rv10_decode_packet(AVCodecContext *avctx, const uint8_t *buf, int buf_size, int buf_size2, int whole_size)
int slice_count
slice count
static const uint8_t rv_sym_run_len[][2]
#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 MPEG-1
static const uint16_t rv_chrom_len_count[15]
void ff_er_add_slice(ERContext *s, int startx, int starty, int endx, int endy, int status)
Add a slice.
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. ...
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
#define RV_GET_MINOR_VER(x)
void ff_mpeg4_init_direct_mv(MpegEncContext *s)
const char * name
Name of the codec implementation.
int low_delay
no reordering needed / has no B-frames
void ff_mpv_common_end(MpegEncContext *s)
void ff_mpeg_flush(AVCodecContext *avctx)
int resync_mb_x
x position of last resync marker
int av_image_check_size(unsigned int w, unsigned int h, int log_offset, void *log_ctx)
Check if the given dimension of an image is valid, meaning that all bytes of the image can be address...
void ff_h263_loop_filter(MpegEncContext *s)
int ff_mpv_export_qp_table(MpegEncContext *s, AVFrame *f, Picture *p, int qp_type)
enum AVPictureType pict_type
Picture type of the frame.
const uint8_t ff_h263_chroma_qscale_table[32]
#define av_assert1(cond)
assert() equivalent, that does not lie in speed critical code.
static av_cold void rv10_init_static(void)
#define RV_GET_MAJOR_VER(x)
Picture * current_picture_ptr
pointer to the current picture
void ff_mpeg_er_frame_start(MpegEncContext *s)
static const uint16_t rv_lum_len_count[15]
static unsigned int show_bits(GetBitContext *s, int n)
Show 1-25 bits.
static int rv10_decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPacket *avpkt)
static av_always_inline int get_vlc2(GetBitContext *s, VLC_TYPE(*table)[2], int bits, int max_depth)
Parse a vlc code.
static av_cold int rv10_decode_end(AVCodecContext *avctx)
#define AVERROR_PATCHWELCOME
Not yet implemented in FFmpeg, patches welcome.
#define MV_TYPE_16X16
1 vector for the whole mb
int first_slice_line
used in MPEG-4 too to handle resync markers
const uint8_t ff_aic_dc_scale_table[32]
static av_cold int rv10_decode_init(AVCodecContext *avctx)
#define AV_LOG_INFO
Standard information.
Libavcodec external API header.
void ff_h263_update_motion_val(MpegEncContext *s)
main external API structure.
int height
picture size. must be a multiple of 16
Tag MUST be and< 10hcoeff half pel interpolation filter coefficients, hcoeff[0] are the 2 middle coefficients[1] are the next outer ones and so on, resulting in a filter like:...eff[2], hcoeff[1], hcoeff[0], hcoeff[0], hcoeff[1], hcoeff[2]...the sign of the coefficients is not explicitly stored but alternates after each coeff and coeff[0] is positive, so...,+,-,+,-,+,+,-,+,-,+,...hcoeff[0] is not explicitly stored but found by subtracting the sum of all stored coefficients with signs from 32 hcoeff[0]=32-hcoeff[1]-hcoeff[2]-...a good choice for hcoeff and htaps is htaps=6 hcoeff={40,-10, 2}an alternative which requires more computations at both encoder and decoder side and may or may not be better is htaps=8 hcoeff={42,-14, 6,-2}ref_frames minimum of the number of available reference frames and max_ref_frames for example the first frame after a key frame always has ref_frames=1spatial_decomposition_type wavelet type 0 is a 9/7 symmetric compact integer wavelet 1 is a 5/3 symmetric compact integer wavelet others are reserved stored as delta from last, last is reset to 0 if always_reset||keyframeqlog quality(logarithmic quantizer scale) stored as delta from last, last is reset to 0 if always_reset||keyframemv_scale stored as delta from last, last is reset to 0 if always_reset||keyframe FIXME check that everything works fine if this changes between framesqbias dequantization bias stored as delta from last, last is reset to 0 if always_reset||keyframeblock_max_depth maximum depth of the block tree stored as delta from last, last is reset to 0 if always_reset||keyframequant_table quantization tableHighlevel bitstream structure:==============================--------------------------------------------|Header|--------------------------------------------|------------------------------------|||Block0||||split?||||yes no||||.........intra?||||:Block01:yes no||||:Block02:.................||||:Block03::y DC::ref index:||||:Block04::cb DC::motion x:||||.........:cr DC::motion y:||||.................|||------------------------------------||------------------------------------|||Block1|||...|--------------------------------------------|------------------------------------|||Y subbands||Cb subbands||Cr subbands||||------||------||------|||||LL0||HL0||||LL0||HL0||||LL0||HL0|||||------||------||------||||------||------||------|||||LH0||HH0||||LH0||HH0||||LH0||HH0|||||------||------||------||||------||------||------|||||HL1||LH1||||HL1||LH1||||HL1||LH1|||||------||------||------||||------||------||------|||||HH1||HL2||||HH1||HL2||||HH1||HL2|||||...||...||...|||------------------------------------|--------------------------------------------Decoding process:=================------------|||Subbands|------------||||------------|Intra DC||||LL0 subband prediction------------|\Dequantization-------------------\||Reference frames|\IDWT|--------------|Motion\|||Frame 0||Frame 1||Compensation.OBMC v-------|--------------|--------------.\------> Frame n output Frame Frame<----------------------------------/|...|-------------------Range Coder:============Binary Range Coder:-------------------The implemented range coder is an adapted version based upon"Range encoding: an algorithm for removing redundancy from a digitised message."by G.N.N.Martin.The symbols encoded by the Snow range coder are bits(0|1).The associated probabilities are not fix but change depending on the symbol mix seen so far.bit seen|new state---------+-----------------------------------------------0|256-state_transition_table[256-old_state];1|state_transition_table[old_state];state_transition_table={0, 0, 0, 0, 0, 0, 0, 0, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 190, 191, 192, 194, 194, 195, 196, 197, 198, 199, 200, 201, 202, 202, 204, 205, 206, 207, 208, 209, 209, 210, 211, 212, 213, 215, 215, 216, 217, 218, 219, 220, 220, 222, 223, 224, 225, 226, 227, 227, 229, 229, 230, 231, 232, 234, 234, 235, 236, 237, 238, 239, 240, 241, 242, 243, 244, 245, 246, 247, 248, 248, 0, 0, 0, 0, 0, 0, 0};FIXME Range Coding of integers:-------------------------FIXME Neighboring Blocks:===================left and top are set to the respective blocks unless they are outside of the image in which case they are set to the Null block top-left is set to the top left block unless it is outside of the image in which case it is set to the left block if this block has no larger parent block or it is at the left side of its parent block and the top right block is not outside of the image then the top right block is used for top-right else the top-left block is used Null block y, cb, cr are 128 level, ref, mx and my are 0 Motion Vector Prediction:=========================1.the motion vectors of all the neighboring blocks are scaled to compensate for the difference of reference frames scaled_mv=(mv *(256 *(current_reference+1)/(mv.reference+1))+128)> the median of the scaled left
void ff_print_debug_info(MpegEncContext *s, Picture *p, AVFrame *pict)
#define SLICE_END
end marker found
static unsigned int get_bits1(GetBitContext *s)
static void skip_bits(GetBitContext *s, int n)
Rational number (pair of numerator and denominator).
int ff_init_vlc_from_lengths(VLC *vlc_arg, int nb_bits, int nb_codes, const int8_t *lens, int lens_wrap, const void *symbols, int symbols_wrap, int symbols_size, int offset, int flags, void *logctx)
Build VLC decoding tables suitable for use with get_vlc2()
static int init_get_bits(GetBitContext *s, const uint8_t *buffer, int bit_size)
Initialize GetBitContext.
int ff_mpv_frame_start(MpegEncContext *s, AVCodecContext *avctx)
generic function called after decoding the header and before a frame is decoded.
int f_code
forward MV resolution
int pict_type
AV_PICTURE_TYPE_I, AV_PICTURE_TYPE_P, AV_PICTURE_TYPE_B, ...
static enum AVPixelFormat pix_fmts[]
and forward the test the status of outputs and forward it to the corresponding return FFERROR_NOT_READY If the filters stores internally one or a few frame for some it can consider them to be part of the FIFO and delay acknowledging a status change accordingly Example code
const uint8_t * c_dc_scale_table
qscale -> c_dc_scale table
int b8_stride
2*mb_width+1 used for some 8x8 block arrays to allow simple addressing
static av_cold void rv10_build_vlc(VLC *vlc, const uint16_t len_count[15], const uint8_t sym_rl[][2], int sym_rl_elems)
struct AVCodecContext * avctx
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
common internal api header.
int mb_stride
mb_width+1 used for some arrays to allow simple addressing of left & top MBs without sig11 ...
void ff_mpv_decode_init(MpegEncContext *s, AVCodecContext *avctx)
Initialize the given MpegEncContext for decoding.
Picture * last_picture_ptr
pointer to the previous picture.
const uint8_t * chroma_qscale_table
qscale -> chroma_qscale (H.263)
av_cold int ff_mpv_common_init(MpegEncContext *s)
init common structure for both encoder and decoder.
static int rv20_decode_picture_header(RVDecContext *rv)
void ff_mpv_frame_end(MpegEncContext *s)
void ff_mpv_reconstruct_mb(MpegEncContext *s, int16_t block[12][64])
int resync_mb_y
y position of last resync marker
int16_t(* block)[64]
points to one of the following blocks
static int ff_thread_once(char *control, void(*routine)(void))
VLC_TYPE(* table)[2]
code, bits
AVRational av_mul_q(AVRational b, AVRational c)
Multiply two rationals.
int * slice_offset
slice offsets in the frame in bytes
int frame_number
Frame counter, set by libavcodec.
int rv10_version
RV10 version: 0 or 3.
int h263_long_vectors
use horrible H.263v1 long vector mode
#define FF_QSCALE_TYPE_MPEG1
#define INIT_VLC_STATIC_OVERLONG
uint64_t_TMPL AV_WL64 unsigned int_TMPL AV_RL32
AVPixelFormat
Pixel format.
This structure stores compressed data.
#define AV_CODEC_CAP_DR1
Codec uses get_buffer() for allocating buffers and supports custom allocators.
uint16_t pb_time
time distance between the last b and p,s,i frame