Go to the documentation of this file.
39 #define H261_MBA_VLC_BITS 8
40 #define H261_MTYPE_VLC_BITS 6
41 #define H261_MV_VLC_BITS 7
42 #define H261_CBP_VLC_BITS 9
43 #define TCOEFF_VLC_BITS 9
44 #define MBA_STUFFING 33
45 #define MBA_STARTCODE 34
92 s->private_ctx = &
h->common;
109 const unsigned block_size = 8 >>
s->avctx->lowres;
111 s->dest[0] += 2 * block_size;
112 s->dest[1] += block_size;
113 s->dest[2] += block_size;
125 if (!
h->gob_start_code_skipped) {
135 h->gob_start_code_skipped = 0;
141 if (
s->mb_height == 18) {
142 if ((
h->gob_number <= 0) || (
h->gob_number > 12))
145 if ((
h->gob_number != 1) && (
h->gob_number != 3) &&
146 (
h->gob_number != 5))
154 if (
s->qscale == 0) {
181 for (
i = mba1;
i < mba2;
i++) {
184 s->mb_x = ((
h->gob_number - 1) % 2) * 11 +
i % 11;
185 s->mb_y = ((
h->gob_number - 1) / 2) * 3 +
i / 11;
186 xy =
s->mb_x +
s->mb_y *
s->mb_stride;
189 for (j = 0; j < 6; j++)
190 s->block_last_index[j] = -1;
200 if (
s->cur_pic.motion_val[0]) {
201 int b_stride = 2*
s->mb_width + 1;
202 int b_xy = 2 *
s->mb_x + (2 *
s->mb_y) * b_stride;
203 s->cur_pic.motion_val[0][b_xy][0] =
s->mv[0][0][0];
204 s->cur_pic.motion_val[0][b_xy][1] =
s->mv[0][0][1];
242 const uint8_t *scan_table;
243 const int qmul =
s->qscale << 1, qadd = (
s->qscale - 1) | 1;
251 scan_table =
s->intra_scantable.permutated;
256 if ((
level & 0x7F) == 0) {
276 block[0] = qmul + qadd;
284 s->block_last_index[n] =
i - 1;
312 }
else if (
level == 0) {
332 s->block_last_index[n] =
i;
351 h->gob_start_code_skipped = 1;
356 if (
h->mba_diff < 0) {
365 h->current_mba +=
h->mba_diff;
370 s->mb_x = ((
h->gob_number - 1) % 2) * 11 + ((
h->current_mba - 1) % 11);
371 s->mb_y = ((
h->gob_number - 1) / 2) * 3 + ((
h->current_mba - 1) / 11);
372 xy =
s->mb_x +
s->mb_y *
s->mb_stride;
377 if (com->
mtype < 0) {
398 if ((
h->current_mba == 1) || (
h->current_mba == 12) ||
399 (
h->current_mba == 23) || (
h->mba_diff != 1)) {
424 s->mv[0][0][0] =
h->current_mv_x * 2;
425 s->mv[0][0][1] =
h->current_mv_y * 2;
427 if (
s->cur_pic.motion_val[0]) {
428 int b_stride = 2*
s->mb_width + 1;
429 int b_xy = 2 *
s->mb_x + (2 *
s->mb_y) * b_stride;
430 s->cur_pic.motion_val[0][b_xy][0] =
s->mv[0][0][0];
431 s->cur_pic.motion_val[0][b_xy][1] =
s->mv[0][0][1];
437 s->bdsp.clear_blocks(
s->block[0]);
438 for (
i = 0;
i < 6;
i++) {
444 for (
i = 0;
i < 6;
i++)
445 s->block_last_index[
i] = -1;
461 uint32_t startcode = 0;
464 startcode = ((startcode << 1) |
get_bits(&
s->gb, 1)) & 0x000FFFFF;
466 if (startcode == 0x10)
470 if (startcode != 0x10) {
527 s->mb_x +
s->mb_y *
s->mb_stride);
532 h->current_mba -
h->mba_diff,
547 if (
pos + 10 > buf_size)
557 const uint8_t *buf = avpkt->
data;
558 int buf_size = avpkt->
size;
562 ff_dlog(avctx,
"*****frame %"PRId64
" size=%d\n", avctx->
frame_num, buf_size);
563 ff_dlog(avctx,
"bytes=%x %x %x %x\n", buf[0], buf[1], buf[2], buf[3]);
565 h->gob_start_code_skipped = 0;
581 if (!
s->context_initialized) {
604 while (
h->gob_number < (
s->mb_height == 18 ? 12 : 5)) {
611 av_assert0(
s->pict_type ==
s->cur_pic.ptr->f->pict_type);
av_cold int ff_mpv_common_init(MpegEncContext *s)
init common structure for both encoder and decoder.
#define MV_TYPE_16X16
1 vector for the whole mb
static int h261_decode_mb(H261DecContext *h)
static int get_bits_left(GetBitContext *gb)
#define AV_EF_COMPLIANT
consider all spec non compliances as errors
#define H261_CBP_VLC_BITS
static int get_bits_count(const GetBitContext *s)
static VLCElem h261_cbp_vlc[512]
This structure describes decoded (raw) audio or video data.
static av_cold void h261_decode_init_static(void)
#define H261_MBA_VLC_BITS
void ff_init_block_index(MpegEncContext *s)
#define UPDATE_CACHE(name, gb)
static int h261_decode_picture_header(H261DecContext *h)
Decode the H.261 picture header.
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 int init_get_bits(GetBitContext *s, const uint8_t *buffer, int bit_size)
Initialize GetBitContext.
static int h261_decode_gob_header(H261DecContext *h)
Decode the group of blocks header or slice header.
static int get_consumed_bytes(MpegEncContext *s, int buf_size)
returns the number of bytes consumed for building the current frame
static void skip_bits(GetBitContext *s, int n)
static unsigned int get_bits(GetBitContext *s, int n)
Read 1-25 bits.
void ff_mpv_reconstruct_mb(MpegEncContext *s, int16_t block[12][64])
#define SKIP_CACHE(name, gb, num)
AVCodec p
The public AVCodec.
enum AVDiscard skip_frame
Skip decoding for selected frames.
#define AV_EF_BITSTREAM
detect bitstream specification deviations
static double val(void *priv, double ch)
#define SLICE_END
end marker found
void ff_mpv_common_end(MpegEncContext *s)
static int ff_thread_once(char *control, void(*routine)(void))
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
#define INIT_FIRST_VLC_RL(rl, static_size)
#define check(x, y, S, v)
#define CLOSE_READER(name, gb)
static av_cold int h261_decode_init(AVCodecContext *avctx)
#define FF_CODEC_DECODE_CB(func)
Filter the word “frame” indicates either a video frame or a group of audio as stored in an AVFrame structure Format for each input and each output the list of supported formats For video that means pixel format For audio that means channel sample format(the sample packing is implied by the sample format) and sample rate. The lists are not just lists
#define SHOW_SBITS(name, gb, num)
static int h261_decode_block(H261DecContext *h, int16_t *block, int n, int coded)
Decode a macroblock.
const uint8_t ff_h261_mba_code[35]
void ff_mpeg_er_frame_start(MpegEncContext *s)
#define av_assert0(cond)
assert() equivalent, that is always enabled.
const uint8_t ff_h261_mv_tab[17][2]
@ AV_PIX_FMT_YUV420P
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
#define CODEC_LONG_NAME(str)
@ AVDISCARD_ALL
discard all
Rational number (pair of numerator and denominator).
@ AV_PICTURE_TYPE_I
Intra.
static unsigned int get_bits1(GetBitContext *s)
void ff_set_qscale(MpegEncContext *s, int qscale)
set qscale and update qscale dependent variables.
int gob_start_code_skipped
static av_always_inline int get_vlc2(GetBitContext *s, const VLCElem *table, int bits, int max_depth)
Parse a vlc code.
static VLCElem h261_mtype_vlc[80]
@ AVDISCARD_NONKEY
discard all frames except keyframes
int(* init)(AVBSFContext *ctx)
#define AV_CODEC_CAP_DR1
Codec uses get_buffer() or get_encode_buffer() for allocating buffers and supports custom allocators.
int av_frame_ref(AVFrame *dst, const AVFrame *src)
Set up a new reference to the data described by the source frame.
int ff_mpv_frame_start(MpegEncContext *s, AVCodecContext *avctx)
generic function called after decoding the header and before a frame is decoded.
#define OPEN_READER(name, gb)
static void skip_bits1(GetBitContext *s)
static int h261_decode_mb_skipped(H261DecContext *h, int mba1, int mba2)
Decode skipped macroblocks.
#define H261_MTYPE_VLC_BITS
static void h261_init_dest(MpegEncContext *s)
static int h261_decode_frame(AVCodecContext *avctx, AVFrame *pict, int *got_frame, AVPacket *avpkt)
void ff_print_debug_info(const MpegEncContext *s, const MPVPicture *p, AVFrame *pict)
#define SKIP_COUNTER(name, gb, num)
const uint8_t ff_h261_cbp_tab[63][2]
#define i(width, name, range_min, range_max)
static unsigned int show_bits(GetBitContext *s, int n)
Show 1-25 bits.
const uint8_t ff_h261_mtype_code[10]
const char * name
Name of the codec implementation.
enum AVPixelFormat pix_fmt
Pixel format, see AV_PIX_FMT_xxx.
#define VLC_INIT_STATIC_SPARSE_TABLE(vlc_table, nb_bits, nb_codes, bits, bits_wrap, bits_size, codes, codes_wrap, codes_size, symbols, symbols_wrap, symbols_size, flags)
const FFCodec ff_h261_decoder
#define GET_RL_VLC(level, run, name, gb, table, bits, max_depth, need_update)
int64_t frame_num
Frame counter, set by libavcodec.
int ff_mpv_decode_init(MpegEncContext *s, AVCodecContext *avctx)
Initialize the given MpegEncContext for decoding.
static VLCElem h261_mba_vlc[540]
static VLCElem h261_mv_vlc[144]
RLTable ff_h261_rl_tcoeff
static int skip_1stop_8data_bits(GetBitContext *gb)
main external API structure.
#define SHOW_UBITS(name, gb, num)
@ AV_PICTURE_TYPE_B
Bi-dir predicted.
const uint16_t ff_h261_mtype_map[10]
#define VLC_INIT_STATIC_TABLE(vlc_table, nb_bits, nb_codes, bits, bits_wrap, bits_size, codes, codes_wrap, codes_size, flags)
const uint8_t ff_h261_mtype_bits[10]
void ff_mpv_frame_end(MpegEncContext *s)
int coded_width
Bitstream width / height, may be different from width/height e.g.
static int h261_decode_gob(H261DecContext *h)
@ AV_PICTURE_TYPE_P
Predicted.
This structure stores compressed data.
static int decode_mv_component(GetBitContext *gb, int v)
The exact code depends on how similar the blocks are and how related they are to the block
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
@ AVDISCARD_NONREF
discard all non reference
const uint8_t ff_h261_mba_bits[35]
#define MB_TYPE_FORWARD_MV
RL_VLC_ELEM * rl_vlc[32]
decoding only
int ff_mpv_decode_close(AVCodecContext *avctx)