38 if (
s->quantizer != quantizer)
40 s->quantizer = quantizer;
49 VP56mv vect[2] = {{0,0}, {0,0}};
56 if (
mvp.x < 0 ||
mvp.x >=
s->mb_width ||
57 mvp.y < 0 ||
mvp.y >=
s->mb_height)
63 if ((
s->macroblocks[
offset].mv.x == vect[0].
x &&
64 s->macroblocks[
offset].mv.y == vect[0].
y) ||
65 (
s->macroblocks[
offset].mv.x == 0 &&
66 s->macroblocks[
offset].mv.y == 0))
69 vect[nb_pred++] =
s->macroblocks[
offset].mv;
74 s->vector_candidate_pos =
pos;
77 s->vector_candidate[0] = vect[0];
78 s->vector_candidate[1] = vect[1];
121 int p02, p34, p0234, p17, p56, p89, p5689, p156789;
136 p156789 = p17 + p5689;
157 uint8_t *mb_type_model =
s->modelp->mb_type[
ctx][prev_type];
173 for (
b=0;
b<4;
b++) {
180 for (
b=0;
b<4;
b++) {
186 s->parse_vector_adjustment(
s, &
s->mv[
b]);
189 s->mv[
b] =
s->vector_candidate[0];
192 s->mv[
b] =
s->vector_candidate[1];
200 s->macroblocks[row *
s->mb_width + col].mv =
s->mv[3];
214 s->macroblocks[row *
s->mb_width + col].type =
s->mb_type;
216 switch (
s->mb_type) {
218 mv = &
s->vector_candidate[0];
222 mv = &
s->vector_candidate[1];
227 mv = &
s->vector_candidate[0];
232 mv = &
s->vector_candidate[1];
236 s->parse_vector_adjustment(
s, &vect);
242 s->parse_vector_adjustment(
s, &vect);
255 s->macroblocks[row*
s->mb_width + col].mv = *
mv;
270 s->macroblocks[row *
s->mb_width + col].type =
s->mb_type;
274 s->macroblocks[row*
s->mb_width + col].mv = *
mv;
285 int idx =
s->idct_scantable[0];
288 for (
b=0;
b<6;
b++) {
289 VP56RefDc *ab = &
s->above_blocks[
s->above_block_idx[
b]];
314 s->block_coeff[
b][idx] += dc;
320 s->block_coeff[
b][idx] *=
s->dequant_dc;
325 ptrdiff_t
stride,
int dx,
int dy)
329 if (dx)
s->vp5dsp.edge_filter_hor(yuv + 10-dx ,
stride, t);
330 if (dy)
s->vp5dsp.edge_filter_ver(yuv +
stride*(10-dy),
stride, t);
332 int * bounding_values =
s->bounding_values_array + 127;
341 ptrdiff_t
stride,
int x,
int y, ptrdiff_t ref_stride)
346 int overlap_offset = 0;
347 int mask =
s->vp56_coord_div[
b] - 1;
348 int deblock_filtering =
s->deblock_filtering;
355 deblock_filtering = 0;
357 dx =
s->mv[
b].x /
s->vp56_coord_div[
b];
358 dy =
s->mv[
b].y /
s->vp56_coord_div[
b];
367 if (
s->interlaced &&
s->il_block) {
369 s->vdsp.emulated_edge_mc(
s->edge_emu_buffer,
370 src +
s->block_offset[
b] + (dy-4)*ref_stride + (dx-2),
371 ref_stride, ref_stride,
373 s->plane_width[plane],
374 s->plane_height[plane]);
375 src_block =
s->edge_emu_buffer;
376 src_offset = 2 + 4*ref_stride;
377 }
else if (x<0 || x+12>=
s->plane_width[plane] ||
378 y<0 || y+12>=
s->plane_height[plane]) {
379 s->vdsp.emulated_edge_mc(
s->edge_emu_buffer,
383 s->plane_width[plane],
384 s->plane_height[plane]);
385 src_block =
s->edge_emu_buffer;
386 src_offset = 2 + 2*
stride;
387 }
else if (deblock_filtering) {
390 s->hdsp.put_pixels_tab[0][0](
s->edge_emu_buffer,
393 src_block =
s->edge_emu_buffer;
394 src_offset = 2 + 2*
stride;
397 src_offset =
s->block_offset[
b] + dy*
stride + dx;
400 if (deblock_filtering)
404 overlap_offset += (
s->mv[
b].x > 0) ? 1 : -1;
408 if (overlap_offset) {
410 s->filter(
s,
dst, src_block, src_offset, src_offset+overlap_offset,
413 s->vp3dsp.put_no_rnd_pixels_l2(
dst, src_block+src_offset,
414 src_block+src_offset+overlap_offset,
417 s->hdsp.put_pixels_tab[1][0](
dst, src_block+src_offset,
stride, 8);
423 if (selector > 10 || selector == 1)
433 else if (selector > 1)
441 int b, ab, b_max, plane, off;
444 ptrdiff_t ref_stride[4];
453 memcpy(ref_stride,
s->stride,
sizeof(
s->stride));
454 if (
s->interlaced &&
s->il_block) {
455 s->block_offset[2] -=
s->stride[0] * 7;
456 s->block_offset[3] -=
s->stride[0] * 7;
461 b_max = 6 - 2*is_alpha;
465 for (
b=0;
b<b_max;
b++) {
468 s->stride[plane],
s->block_coeff[
b],
s->idct_selector[
b]);
474 for (
b=0;
b<b_max;
b++) {
476 off =
s->block_offset[
b];
477 s->hdsp.put_pixels_tab[1][0](frame_current->
data[plane] + off,
479 s->stride[plane], 8);
481 s->stride[plane],
s->block_coeff[
b],
s->idct_selector[
b]);
492 for (
b=0;
b<b_max;
b++) {
493 int x_off =
b==1 ||
b==3 ? 8 : 0;
494 int y_off =
b==2 ||
b==3 ? (
s->interlaced &&
s->il_block ? 1 : 8) : 0;
497 16*col+x_off, 16*row+y_off, ref_stride[plane]);
499 s->stride[plane],
s->block_coeff[
b],
s->idct_selector[
b]);
505 s->block_coeff[4][0] = 0;
506 s->block_coeff[5][0] = 0;
509 if (
s->interlaced &&
s->il_block) {
511 s->block_offset[2] +=
s->stride[0] * 7;
512 s->block_offset[3] +=
s->stride[0] * 7;
522 int prob =
s->il_prob;
539 ret =
s->parse_coeff(
s);
569 s->plane_width[1] =
s->plane_width[2] = avctx->
coded_width/2;
573 s->have_undamaged_frame = 0;
581 if (
s->mb_width > 1000 ||
s->mb_height > 1000) {
588 sizeof(*
s->above_blocks));
590 sizeof(*
s->macroblocks));
593 s->edge_emu_buffer =
s->edge_emu_buffer_alloc;
594 if (!
s->above_blocks || !
s->macroblocks || !
s->edge_emu_buffer_alloc)
597 s->edge_emu_buffer += 15 *
stride * 2;
599 if (
s->alpha_context)
610 const uint8_t *buf = avpkt->
data;
613 int remaining_buf_size = avpkt->
size;
614 int alpha_offset = remaining_buf_size;
619 if (remaining_buf_size < 3)
621 alpha_offset = bytestream_get_be24(&buf);
622 remaining_buf_size -= 3;
623 if (remaining_buf_size < alpha_offset)
627 res =
s->parse_header(
s, buf, alpha_offset);
632 for (
i = 0;
i < 4;
i++) {
634 if (
s->alpha_context)
664 int bak_w = avctx->
width;
665 int bak_h = avctx->
height;
669 remaining_buf_size -= alpha_offset;
671 res =
s->alpha_context->parse_header(
s->alpha_context, buf, remaining_buf_size);
675 avctx->
width = bak_w;
685 s->discard_frame = 0;
688 if (
s->discard_frame)
699 int jobnr,
int threadnr)
702 int is_alpha = (jobnr == 1);
703 VP56Context *
s = is_alpha ? s0->alpha_context : s0;
705 int mb_row, mb_col, mb_row_flip, mb_offset = 0;
707 ptrdiff_t stride_y, stride_uv;
713 s->default_models_init(
s);
719 s->parse_vector_models(
s);
723 if (
s->parse_coeff_models(
s))
731 memset(
s->prev_dc, 0,
sizeof(
s->prev_dc));
737 s->above_blocks[
block].dc_coeff = 0;
738 s->above_blocks[
block].not_null_dc = 0;
743 stride_y = p->linesize[0];
744 stride_uv = p->linesize[1];
750 for (mb_row=0; mb_row<
s->mb_height; mb_row++) {
752 mb_row_flip =
s->mb_height - mb_row - 1;
754 mb_row_flip = mb_row;
758 s->left_block[
block].dc_coeff = 0;
759 s->left_block[
block].not_null_dc = 0;
761 memset(
s->coeff_ctx, 0,
sizeof(
s->coeff_ctx));
762 memset(
s->coeff_ctx_last, 24,
sizeof(
s->coeff_ctx_last));
764 s->above_block_idx[0] = 1;
765 s->above_block_idx[1] = 2;
766 s->above_block_idx[2] = 1;
767 s->above_block_idx[3] = 2;
768 s->above_block_idx[4] = 2*
s->mb_width + 2 + 1;
769 s->above_block_idx[5] = 3*
s->mb_width + 4 + 1;
771 s->block_offset[
s->frbi] = (mb_row_flip*16 + mb_offset) * stride_y;
772 s->block_offset[
s->srbi] =
s->block_offset[
s->frbi] + 8*stride_y;
773 s->block_offset[1] =
s->block_offset[0] + 8;
774 s->block_offset[3] =
s->block_offset[2] + 8;
775 s->block_offset[4] = (mb_row_flip*8 + mb_offset) * stride_uv;
776 s->block_offset[5] =
s->block_offset[4];
778 for (mb_col=0; mb_col<
s->mb_width; mb_col++) {
784 s->discard_frame = 1;
792 for (y=0; y<4; y++) {
793 s->above_block_idx[y] += 2;
794 s->block_offset[y] += 16;
797 for (uv=4; uv<6; uv++) {
798 s->above_block_idx[uv] += 1;
799 s->block_offset[uv] += 8;
805 s->have_undamaged_frame = 1;
820 int flip,
int has_alpha)
832 for (
i = 0;
i < 64;
i++) {
833#define TRANSPOSE(x) (((x) >> 3) | (((x) & 7) << 3))
843 s->edge_emu_buffer_alloc =
NULL;
845 s->above_blocks =
NULL;
846 s->macroblocks =
NULL;
848 s->deblock_filtering = 1;
853 s->has_alpha = has_alpha;
855 s->modelp = &
s->model;
uint8_t ptrdiff_t const uint8_t ptrdiff_t int intptr_t intptr_t int int16_t * dst
static AVFormatContext * ctx
Libavcodec external API header.
#define i(width, name, range_min, range_max)
#define prob(name, subs,...)
int ff_get_buffer(AVCodecContext *avctx, AVFrame *frame, int flags)
Get a buffer for a frame.
int ff_set_dimensions(AVCodecContext *s, int width, int height)
#define AV_GET_BUFFER_FLAG_REF
The decoder will keep a reference to the frame and may reuse it later.
@ AVDISCARD_ALL
discard all
@ AVDISCARD_NONKEY
discard all frames except keyframes
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
#define AV_FRAME_FLAG_INTERLACED
A flag to mark frames whose content is interlaced.
#define AV_FRAME_FLAG_KEY
A flag to mark frames that are keyframes.
void av_frame_unref(AVFrame *frame)
Unreference all the buffers referenced by frame and reset the frame fields.
int av_frame_replace(AVFrame *dst, const AVFrame *src)
Ensure the destination frame refers to the same data described by the source frame,...
int av_frame_ref(AVFrame *dst, const AVFrame *src)
Set up a new reference to the data described by the source frame.
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
AVFrame * av_frame_alloc(void)
Allocate an AVFrame and set its fields to default values.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
int av_reallocp_array(void *ptr, size_t nmemb, size_t size)
Allocate, reallocate an array through a pointer to a pointer.
@ AV_PICTURE_TYPE_I
Intra.
@ AV_PICTURE_TYPE_P
Predicted.
static const int8_t mv[256][2]
av_cold void ff_h264chroma_init(H264ChromaContext *c, int bit_depth)
av_cold void ff_hpeldsp_init(HpelDSPContext *c, int flags)
static void flip(AVCodecContext *avctx, AVFrame *frame)
av_cold void ff_videodsp_init(VideoDSPContext *ctx, int bpc)
void ff_vp3dsp_set_bounding_values(int *bounding_values_array, int filter_limit)
av_cold void ff_vp3dsp_init(VP3DSPContext *c)
void ff_vp3dsp_idct10_put(uint8_t *dest, ptrdiff_t stride, int16_t *block)
void ff_vp3dsp_idct10_add(uint8_t *dest, ptrdiff_t stride, int16_t *block)
static const uint16_t mask[17]
#define FFSWAP(type, a, b)
const uint8_t ff_zigzag_direct[64]
Memory handling functions.
@ AV_PIX_FMT_YUV420P
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
@ AV_PIX_FMT_YUVA420P
planar YUV 4:2:0, 20bpp, (1 Cr & Cb sample per 2x2 Y & A samples)
#define FF_ARRAY_ELEMS(a)
main external API structure.
enum AVPixelFormat pix_fmt
Pixel format, see AV_PIX_FMT_xxx.
int width
picture width / height.
int error_concealment
error concealment flags
int skip_alpha
Skip processing alpha if supported by codec.
int flags
AV_CODEC_FLAG_*.
int(* execute2)(struct AVCodecContext *c, int(*func)(struct AVCodecContext *c2, void *arg, int jobnr, int threadnr), void *arg2, int *ret, int count)
The codec may call this to execute several independent things.
int coded_width
Bitstream width / height, may be different from width/height e.g.
This structure describes decoded (raw) audio or video data.
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
This structure stores compressed data.
uint8_t mb_types_stats[3][10][2]
uint8_t mb_type[3][10][10]
static int frame_ref(AVFrame *dst, const AVFrame *src, const int plane_copy[4])
void ff_vp3dsp_h_loop_filter_12(uint8_t *first_pixel, ptrdiff_t stride, int *bounding_values)
void ff_vp3dsp_v_loop_filter_12(uint8_t *first_pixel, ptrdiff_t stride, int *bounding_values)
static void vp56_parse_mb_type_models(VP56Context *s)
static void vp56_deblock_filter(VP56Context *s, uint8_t *yuv, ptrdiff_t stride, int dx, int dy)
static void vp56_add_predictors_dc(VP56Context *s, VP56Frame ref_frame)
static VP56mb vp56_conceal_mv(VP56Context *s, int row, int col)
av_cold int ff_vp56_init_context(AVCodecContext *avctx, VP56Context *s, int flip, int has_alpha)
Initializes an VP56Context.
av_cold int ff_vp56_free_context(VP56Context *s)
void ff_vp56_init_dequant(VP56Context *s, int quantizer)
static int vp56_size_changed(VP56Context *s)
static void vp56_idct_add(VP56Context *s, uint8_t *dest, ptrdiff_t stride, int16_t *block, int selector)
static int ff_vp56_decode_mbs(AVCodecContext *avctx, void *, int, int)
static void vp56_decode_4mv(VP56Context *s, int row, int col)
static int vp56_conceal_mb(VP56Context *s, int row, int col, int is_alpha)
int ff_vp56_decode_frame(AVCodecContext *avctx, AVFrame *rframe, int *got_frame, AVPacket *avpkt)
static av_always_inline void vp56_render_mb(VP56Context *s, int row, int col, int is_alpha, VP56mb mb_type)
static void vp56_idct_put(VP56Context *s, uint8_t *dest, ptrdiff_t stride, int16_t *block, int selector)
static int vp56_get_vectors_predictors(VP56Context *s, int row, int col, VP56Frame ref_frame)
static int vp56_decode_mb(VP56Context *s, int row, int col, int is_alpha)
static VP56mb vp56_decode_mv(VP56Context *s, int row, int col)
static void vp56_mc(VP56Context *s, int b, int plane, uint8_t *src, ptrdiff_t stride, int x, int y, ptrdiff_t ref_stride)
static VP56mb vp56_parse_mb_type(VP56Context *s, VP56mb prev_type, int ctx)
VP5 and VP6 compatible video decoder (common features)
static int vp56_rac_gets(VPXRangeCoder *c, int bits)
vp56 specific range coder implementation
@ VP56_MB_INTER_V1_PF
Inter MB, first vector, from previous frame.
@ VP56_MB_INTER_DELTA_PF
Inter MB, above/left vector + delta, from previous frame.
@ VP56_MB_INTER_DELTA_GF
Inter MB, above/left vector + delta, from golden frame.
@ VP56_MB_INTER_V2_PF
Inter MB, second vector, from previous frame.
@ VP56_MB_INTER_V2_GF
Inter MB, second vector, from golden frame.
@ VP56_MB_INTER_V1_GF
Inter MB, first vector, from golden frame.
@ VP56_MB_INTER_4V
Inter MB, 4 vectors, from previous frame.
@ VP56_MB_INTER_NOVEC_GF
Inter MB, no vector, from golden frame.
@ VP56_MB_INTER_NOVEC_PF
Inter MB, no vector, from previous frame.
static av_always_inline int vp56_rac_get_tree(VPXRangeCoder *c, const VP56Tree *tree, const uint8_t *probs)
const VP56Tree ff_vp56_pmbt_tree[]
const int8_t ff_vp56_candidate_predictor_pos[12][2]
const uint8_t ff_vp56_b2p[]
const uint8_t ff_vp56_pre_def_mb_type_stats[16][3][10][2]
const uint8_t ff_vp56_mb_type_model_model[]
const VP56Frame ff_vp56_reference_frame[]
const uint8_t ff_vp56_b6to4[]
const uint8_t ff_vp56_ac_dequant[64]
const uint8_t ff_vp56_dc_dequant[64]
const VP56Tree ff_vp56_pmbtm_tree[]
const uint8_t ff_vp56_filter_threshold[]
VP5 and VP6 compatible video decoder (common data)
Common VP5-VP9 range decoder stuff.
static av_always_inline int vpx_rac_get_prob_branchy(VPXRangeCoder *c, int prob)
static av_always_inline int vpx_rac_get(VPXRangeCoder *c)
static int ref_frame(VVCFrame *dst, const VVCFrame *src)
static void mvp(const VVCLocalContext *lc, const int mvp_lx_flag, const int lx, const int8_t *ref_idx, const int amvr_shift, Mv *mv)