Go to the documentation of this file.
   41 #define SLICE_ERROR     -1 
   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 
  107     s->private_ctx = &
h->common;
 
  124     const unsigned block_size = 8 >> 
s->avctx->lowres;
 
  126     s->dest[0] += 2 * block_size;
 
  127     s->dest[1] += block_size;
 
  128     s->dest[2] += block_size;
 
  140     if (!
h->gob_start_code_skipped) {
 
  150     h->gob_start_code_skipped = 0;
 
  156     if (
s->mb_height == 18) { 
 
  157         if ((
h->gob_number <= 0) || (
h->gob_number > 12))
 
  160         if ((
h->gob_number != 1) && (
h->gob_number != 3) &&
 
  161             (
h->gob_number != 5))
 
  169     if (
s->qscale == 0) {
 
  197     for (
i = mba1; 
i < mba2; 
i++) {
 
  200         s->mb_x = ((
h->gob_number - 1) % 2) * 11 + 
i % 11;
 
  201         s->mb_y = ((
h->gob_number - 1) / 2) * 3 + 
i / 11;
 
  202         xy      = 
s->mb_x + 
s->mb_y * 
s->mb_stride;
 
  205         for (j = 0; j < 6; j++)
 
  206             s->block_last_index[j] = -1;
 
  216         if (
s->cur_pic.motion_val[0]) {
 
  217             int b_stride = 2*
s->mb_width + 1;
 
  218             int b_xy     = 2 * 
s->mb_x + (2 * 
s->mb_y) * b_stride;
 
  219             s->cur_pic.motion_val[0][b_xy][0] = 
s->mv[0][0][0];
 
  220             s->cur_pic.motion_val[0][b_xy][1] = 
s->mv[0][0][1];
 
  258     const uint8_t *scan_table;
 
  259     const int qmul = 
s->qscale << 1, qadd = (
s->qscale - 1) | 1;
 
  267     scan_table = 
s->intra_scantable.permutated;
 
  272         if ((
level & 0x7F) == 0) {
 
  292             block[0] = qmul + qadd;
 
  300         s->block_last_index[n] = 
i - 1;
 
  328         } 
else if (
level == 0) {
 
  348     s->block_last_index[n] = 
i;
 
  367             h->gob_start_code_skipped = 1;
 
  372     if (
h->mba_diff < 0) {
 
  381     h->current_mba += 
h->mba_diff;
 
  386     s->mb_x = ((
h->gob_number - 1) % 2) * 11 + ((
h->current_mba - 1) % 11);
 
  387     s->mb_y = ((
h->gob_number - 1) / 2) * 3 + ((
h->current_mba - 1) / 11);
 
  388     xy      = 
s->mb_x + 
s->mb_y * 
s->mb_stride;
 
  393     if (com->
mtype < 0) {
 
  417         if ((
h->current_mba ==  1) || (
h->current_mba == 12) ||
 
  418             (
h->current_mba == 23) || (
h->mba_diff != 1)) {
 
  443     s->mv[0][0][0]                 = 
h->current_mv_x * 2; 
 
  444     s->mv[0][0][1]                 = 
h->current_mv_y * 2;
 
  446     if (
s->cur_pic.motion_val[0]) {
 
  447         int b_stride = 2*
s->mb_width + 1;
 
  448         int b_xy     = 2 * 
s->mb_x + (2 * 
s->mb_y) * b_stride;
 
  449         s->cur_pic.motion_val[0][b_xy][0] = 
s->mv[0][0][0];
 
  450         s->cur_pic.motion_val[0][b_xy][1] = 
s->mv[0][0][1];
 
  456         s->bdsp.clear_blocks(
h->block[0]);
 
  457         for (
i = 0; 
i < 6; 
i++) {
 
  463         for (
i = 0; 
i < 6; 
i++)
 
  464             s->block_last_index[
i] = -1;
 
  479     uint32_t startcode = 0;
 
  482         startcode = ((startcode << 1) | 
get_bits(&
h->gb, 1)) & 0x000FFFFF;
 
  484         if (startcode == 0x10)
 
  488     if (startcode != 0x10) {
 
  538                    s->mb_x + 
s->mb_y * 
s->mb_stride);
 
  543                                h->current_mba - 
h->mba_diff,
 
  554     const uint8_t *buf = avpkt->
data;
 
  555     int buf_size       = avpkt->
size;
 
  559     ff_dlog(avctx, 
"*****frame %"PRId64
" size=%d\n", avctx->
frame_num, buf_size);
 
  560     ff_dlog(avctx, 
"bytes=%x %x %x %x\n", buf[0], buf[1], buf[2], buf[3]);
 
  562     h->gob_start_code_skipped = 0;
 
  578     if (!
s->context_initialized) {
 
  600     while (
h->gob_number < (
s->mb_height == 18 ? 12 : 5)) {
 
  
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)
av_cold int ff_mpv_decode_init(MpegEncContext *s, AVCodecContext *avctx)
Initialize the given MpegEncContext for decoding.
#define AV_EF_COMPLIANT
consider all spec non compliances as errors
#define H261_CBP_VLC_BITS
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)
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 void skip_bits(GetBitContext *s, int n)
static unsigned int get_bits(GetBitContext *s, int n)
Read 1-25 bits.
#define SKIP_CACHE(name, gb, num)
AVCodec p
The public AVCodec.
static int h261_decode_picture_header(H261DecContext *h, int *is_key)
Decode the H.261 picture header.
enum AVDiscard skip_frame
Skip decoding for selected frames.
#define AV_EF_BITSTREAM
detect bitstream specification deviations
static double val(void *priv, double ch)
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 AV_FRAME_FLAG_KEY
A flag to mark frames that are keyframes.
#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)
#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)
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)
av_cold void ff_mpv_common_end(MpegEncContext *s)
@ AVDISCARD_ALL
discard all
New swscale design to change SwsGraph is what coordinates multiple passes These can include cascaded scaling error diffusion and so on Or we could have separate passes for the vertical and horizontal scaling In between each SwsPass lies a fully allocated image buffer Graph passes may have different levels of e g we can have a single threaded error diffusion pass following a multi threaded scaling pass SwsGraph is internally recreated whenever the image format
Rational number (pair of numerator and denominator).
av_cold int ff_mpv_decode_close(AVCodecContext *avctx)
@ AV_PICTURE_TYPE_I
Intra.
static unsigned int get_bits1(GetBitContext *s)
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]
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.
#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...
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]
@ AVDISCARD_NONINTRA
discard all non intra frames
#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.
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)
#define SLICE_END
end marker found
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.
void ff_mpv_reconstruct_mb(MPVContext *s, int16_t block[][64])
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.
DECLARE_ALIGNED_32(int16_t, block)[6][64]
const uint8_t ff_h261_mba_bits[35]
#define MB_TYPE_FORWARD_MV
RL_VLC_ELEM * rl_vlc[32]
decoding only