44#define H261_MBA_VLC_BITS 8
45#define H261_MTYPE_VLC_BITS 6
46#define H261_MV_VLC_BITS 7
47#define H261_CBP_VLC_BITS 9
48#define TCOEFF_VLC_BITS 9
49#define MBA_STUFFING 33
50#define MBA_STARTCODE 34
121 const unsigned block_size = 8 >>
s->avctx->lowres;
123 s->dest[0] += 2 * block_size;
124 s->dest[1] += block_size;
125 s->dest[2] += block_size;
137 if (!
h->gob_start_code_skipped) {
147 h->gob_start_code_skipped = 0;
153 if (
s->mb_height == 18) {
154 if ((
h->gob_number <= 0) || (
h->gob_number > 12))
157 if ((
h->gob_number != 1) && (
h->gob_number != 3) &&
158 (
h->gob_number != 5))
166 if (
s->qscale == 0) {
193 for (
i = mba1;
i < mba2;
i++) {
196 s->mb_x = ((
h->gob_number - 1) % 2) * 11 +
i % 11;
197 s->mb_y = ((
h->gob_number - 1) / 2) * 3 +
i / 11;
198 xy =
s->mb_x +
s->mb_y *
s->mb_stride;
201 for (j = 0; j < 6; j++)
202 s->block_last_index[j] = -1;
212 if (
s->cur_pic.motion_val[0]) {
213 int b_stride = 2*
s->mb_width + 1;
214 int b_xy = 2 *
s->mb_x + (2 *
s->mb_y) * b_stride;
215 s->cur_pic.motion_val[0][b_xy][0] =
s->mv[0][0][0];
216 s->cur_pic.motion_val[0][b_xy][1] =
s->mv[0][0][1];
252 const uint8_t *scan_table;
253 const int qmul =
s->qscale << 1, qadd = (
s->qscale - 1) | 1;
261 scan_table =
s->intra_scantable.permutated;
266 if ((
level & 0x7F) == 0) {
286 block[0] = qmul + qadd;
294 s->block_last_index[n] =
i - 1;
322 }
else if (
level == 0) {
342 s->block_last_index[n] =
i;
360 h->gob_start_code_skipped = 1;
365 if (
h->mba_diff < 0) {
374 h->current_mba +=
h->mba_diff;
379 s->mb_x = ((
h->gob_number - 1) % 2) * 11 + ((
h->current_mba - 1) % 11);
380 s->mb_y = ((
h->gob_number - 1) / 2) * 3 + ((
h->current_mba - 1) / 11);
381 xy =
s->mb_x +
s->mb_y *
s->mb_stride;
410 if ((
h->current_mba == 1) || (
h->current_mba == 12) ||
411 (
h->current_mba == 23) || (
h->mba_diff != 1)) {
436 s->mv[0][0][0] =
h->current_mv_x * 2;
437 s->mv[0][0][1] =
h->current_mv_y * 2;
439 if (
s->cur_pic.motion_val[0]) {
440 int b_stride = 2*
s->mb_width + 1;
441 int b_xy = 2 *
s->mb_x + (2 *
s->mb_y) * b_stride;
442 s->cur_pic.motion_val[0][b_xy][0] =
s->mv[0][0][0];
443 s->cur_pic.motion_val[0][b_xy][1] =
s->mv[0][0][1];
449 s->bdsp.clear_blocks(
h->block[0]);
450 for (
i = 0;
i < 6;
i++) {
456 for (
i = 0;
i < 6;
i++)
457 s->block_last_index[
i] = -1;
472 uint32_t startcode = 0;
475 startcode = ((startcode << 1) |
get_bits(&
h->gb, 1)) & 0x000FFFFF;
477 if (startcode == 0x10)
481 if (startcode != 0x10) {
531 s->mb_x +
s->mb_y *
s->mb_stride);
536 h->current_mba -
h->mba_diff,
547 const uint8_t *buf = avpkt->
data;
548 int buf_size = avpkt->
size;
552 ff_dlog(avctx,
"*****frame %"PRId64
" size=%d\n", avctx->
frame_num, buf_size);
553 ff_dlog(avctx,
"bytes=%x %x %x %x\n", buf[0], buf[1], buf[2], buf[3]);
555 h->gob_start_code_skipped = 0;
571 if (!
s->context_initialized) {
593 while (
h->gob_number < (
s->mb_height == 18 ? 12 : 5)) {
static double val(void *priv, double ch)
static const char *const format[]
const FFCodec ff_h261_decoder
Libavcodec external API header.
#define i(width, name, range_min, range_max)
#define FF_CODEC_CAP_SKIP_FRAME_FILL_PARAM
The decoder extracts and fills its parameters even if the frame is skipped due to the skip_frame sett...
#define FF_CODEC_DECODE_CB(func)
#define CODEC_LONG_NAME(str)
int ff_set_dimensions(AVCodecContext *s, int width, int height)
#define AV_EF_BITSTREAM
detect bitstream specification deviations
#define AV_EF_COMPLIANT
consider all spec non compliances as errors
int(* init)(AVBSFContext *ctx)
bitstream reader API header.
static av_always_inline int get_vlc2(GetBitContext *s, const VLCElem *table, int bits, int max_depth)
Parse a vlc code.
#define SKIP_CACHE(name, gb, num)
#define CLOSE_READER(name, gb)
static int get_bits_left(GetBitContext *gb)
#define SHOW_UBITS(name, gb, num)
static unsigned int get_bits1(GetBitContext *s)
#define SHOW_SBITS(name, gb, num)
#define OPEN_READER(name, gb)
static void skip_bits(GetBitContext *s, int n)
static int skip_1stop_8data_bits(GetBitContext *gb)
#define GET_RL_VLC(level, run, name, gb, table, bits, max_depth, need_update)
#define UPDATE_CACHE(name, gb)
static void skip_bits1(GetBitContext *s)
static unsigned int get_bits(GetBitContext *s, int n)
Read 1-25 bits.
#define SKIP_COUNTER(name, gb, num)
static unsigned int show_bits(GetBitContext *s, int n)
Show 1-25 bits.
static int init_get_bits(GetBitContext *s, const uint8_t *buffer, int bit_size)
Initialize GetBitContext.
#define AV_CODEC_CAP_DR1
Codec uses get_buffer() or get_encode_buffer() for allocating buffers and supports custom allocators.
@ AVDISCARD_ALL
discard all
@ AVDISCARD_NONINTRA
discard all non intra frames
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
#define AV_FRAME_FLAG_KEY
A flag to mark frames that are keyframes.
int av_frame_ref(AVFrame *dst, const AVFrame *src)
Set up a new reference to the data described by the source frame.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
@ AV_PICTURE_TYPE_I
Intra.
@ AV_PICTURE_TYPE_P
Predicted.
RLTable ff_h261_rl_tcoeff
const uint16_t ff_h261_mtype_map[10]
const uint8_t ff_h261_mv_tab[17][2]
const uint8_t ff_h261_mtype_bits[10]
const uint8_t ff_h261_mtype_code[10]
const uint8_t ff_h261_mba_code[35]
const uint8_t ff_h261_cbp_tab[63][2]
const uint8_t ff_h261_mba_bits[35]
static int h261_decode_frame(AVCodecContext *avctx, AVFrame *pict, int *got_frame, AVPacket *avpkt)
static int h261_decode_gob(H261DecContext *h)
static VLCElem h261_mtype_vlc[80]
static int h261_decode_mb(H261DecContext *h)
#define H261_MTYPE_VLC_BITS
static VLCElem h261_cbp_vlc[512]
#define H261_MBA_VLC_BITS
#define SLICE_END
end marker found
static int h261_decode_picture_header(H261DecContext *h, int *is_key)
Decode the H.261 picture header.
static void h261_init_dest(MpegEncContext *s)
static av_cold int h261_decode_init(AVCodecContext *avctx)
#define H261_CBP_VLC_BITS
static av_cold void h261_decode_init_static(void)
static int h261_decode_gob_header(H261DecContext *h)
Decode the group of blocks header or slice header.
static VLCElem h261_mv_vlc[144]
static int h261_decode_block(H261DecContext *h, int16_t *block, int n, int coded)
Decode a macroblock.
static VLCElem h261_mba_vlc[540]
static int decode_mv_component(GetBitContext *gb, int v)
static void h261_decode_mb_skipped(H261DecContext *h, int mba1, int mba2)
Decode skipped macroblocks.
static int ff_thread_once(char *control, void(*routine)(void))
#define check(x, y, S, v)
void ff_mpeg_er_frame_start(MpegEncContext *s)
#define MB_TYPE_FORWARD_MV
av_cold int ff_mpv_common_init(MpegEncContext *s)
init common structure for both encoder and decoder.
av_cold void ff_mpv_common_end(MpegEncContext *s)
void ff_init_block_index(MpegEncContext *s)
#define MV_TYPE_16X16
1 vector for the whole mb
int ff_mpv_frame_start(MpegEncContext *s, AVCodecContext *avctx)
generic function called after decoding the header and before a frame is decoded.
void ff_mpv_frame_end(MpegEncContext *s)
void ff_print_debug_info(const MpegEncContext *s, const MPVPicture *p, AVFrame *pict)
av_cold int ff_mpv_decode_close(AVCodecContext *avctx)
void ff_mpv_reconstruct_mb(MPVContext *s, int16_t block[][64])
av_cold int ff_mpv_decode_init(MpegEncContext *s, AVCodecContext *avctx)
Initialize the given MpegEncContext for decoding.
mpegvideo decoder header.
@ AV_PIX_FMT_YUV420P
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
#define INIT_FIRST_VLC_RL(rl, static_size)
main external API structure.
enum AVPixelFormat pix_fmt
Pixel format, see AV_PIX_FMT_xxx.
int64_t frame_num
Frame counter, set by libavcodec.
int coded_width
Bitstream width / height, may be different from width/height e.g.
enum AVDiscard skip_frame
Skip decoding for selected frames.
This structure describes decoded (raw) audio or video data.
This structure stores compressed data.
Rational number (pair of numerator and denominator).
int gob_start_code_skipped
DECLARE_ALIGNED_32(int16_t, block)[6][64]
RL_VLC_ELEM * rl_vlc[32]
decoding only
#define VLC_INIT_STATIC_TABLE(vlc_table, nb_bits, nb_codes, bits, bits_wrap, bits_size, codes, codes_wrap, codes_size, flags)
#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)