25#include "config_components.h"
47#define H264_CHROMA_MC(OPNAME, OP)\
48static void OPNAME ## h264_chroma_mc1(uint8_t *dst , const uint8_t *src , ptrdiff_t stride, int h, int x, int y)\
50 const int A = (8-x) * (8-y);\
51 const int B = ( x) * (8-y);\
52 const int C = (8-x) * ( y);\
53 const int D = ( x) * ( y);\
55 av_assert2(x < 8 && y < 8 && x >= 0 && y >= 0);\
58 for (int i = 0; i < h; ++i) {\
59 OP(dst[0], (A*src[0] + B*src[1] + C*src[stride+0] + D*src[stride+1]));\
65 const int step = C ? stride : 1;\
66 for (int i = 0; i < h; ++i) {\
67 OP(dst[0], (A*src[0] + E*src[step+0]));\
72 for (int i = 0; i < h; ++i) {\
73 OP(dst[0], (A*src[0]));\
80#define op_avg(a, b) a = (((a)+(((b) + 32)>>6)+1)>>1)
81#define op_put(a, b) a = (((b) + 32)>>6)
93 s->width = avctx->coded_width;
94 s->height = avctx->coded_height;
95 s->codec_id = avctx->codec->id;
96 s->workaround_bugs = avctx->workaround_bugs;
110 s->h264chroma.avg_h264_chroma_pixels_tab[3] = avg_h264_chroma_mc1;
111 s->h264chroma.put_h264_chroma_pixels_tab[3] = put_h264_chroma_mc1;
119 if (!
s->picture_pool)
137 if (
s->height != s1->
height ||
s->width != s1->
width ||
s->context_reinit) {
185 if (!
s->context_initialized)
194 if ((
s->width ||
s->height) &&
208 memset(
s->thread_context, 0,
sizeof(
s->thread_context));
209 s->thread_context[0] =
s;
211 if (
s->width &&
s->height) {
216 s->context_reinit = 0;
221 s->context_reinit = 1;
262 av_assert1(
s->mb_width ==
s->buffer_pools.alloc_mb_width);
263 av_assert1(
s->mb_height ==
s->buffer_pools.alloc_mb_height ||
264 FFALIGN(
s->mb_height, 2) ==
s->buffer_pools.alloc_mb_height);
265 av_assert1(
s->mb_stride ==
s->buffer_pools.alloc_mb_stride);
267 &
s->buffer_pools,
s->mb_height);
294 int h_chroma_shift, v_chroma_shift;
296 for (
int i = 0;
i <
frame->height;
i++)
315 av_assert1(!
s->last_pic.ptr ||
s->last_pic.ptr->f->buf[0]);
316 av_assert1(!
s->next_pic.ptr ||
s->next_pic.ptr->f->buf[0]);
320 "allocating dummy last picture for B frame\n");
324 "warning: first frame is no keyframe\n");
344 s->last_pic.ptr->f->buf[0]));
372 (!
s->progressive_frame && !
s->progressive_sequence);
373 s->cur_pic.ptr->field_picture =
s->picture_structure !=
PICT_FRAME;
375 s->cur_pic.ptr->f->pict_type =
s->pict_type;
386 ff_dlog(
s->avctx,
"L%p N%p C%p L%p N%p C%p type:%d drop:%d\n",
387 (
void*)
s->last_pic.ptr, (
void*)
s->next_pic.ptr, (
void*)
s->cur_pic.ptr,
388 s->last_pic.ptr ?
s->last_pic.ptr->f->data[0] :
NULL,
389 s->next_pic.ptr ?
s->next_pic.ptr->f->data[0] :
NULL,
390 s->cur_pic.ptr ?
s->cur_pic.ptr->f->data[0] :
NULL,
391 s->pict_type,
s->droppable);
408 if (
s->cur_pic.reference)
415 p->qscale_table, p->motion_val,
416 p->mb_width, p->mb_height, p->mb_stride,
s->quarter_sample);
424 unsigned int nb_mb = p->mb_height * p->mb_width;
433 for (
unsigned y = 0; y < p->mb_height; y++)
434 for (
unsigned x = 0; x < p->mb_width; x++) {
435 const unsigned int block_idx = y * p->mb_width + x;
436 const unsigned int mb_xy = y * p->mb_stride + x;
444 b->delta_qp = p->qscale_table[mb_xy] *
mult;
453 s->last_pic.ptr ?
s->last_pic.ptr->f :
NULL,
454 y,
h,
s->picture_structure,
455 s->first_field,
s->low_delay);
466 s->mb_x =
s->mb_y = 0;
472 uint8_t *dest,
const uint8_t *
src,
473 int field_based,
int field_select,
474 int src_x,
int src_y,
476 int h_edge_pos,
int v_edge_pos,
478 int motion_x,
int motion_y)
480 const int lowres =
s->avctx->lowres;
481 const int op_index =
lowres;
482 const int s_mask = (2 <<
lowres) - 1;
488 if (
s->quarter_sample) {
493 sx = motion_x & s_mask;
494 sy = motion_y & s_mask;
495 src_x += motion_x >>
lowres + 1;
496 src_y += motion_y >>
lowres + 1;
500 if ((
unsigned)src_x >
FFMAX( h_edge_pos - (!!sx) -
w, 0) ||
501 (
unsigned)src_y >
FFMAX((v_edge_pos >> field_based) - (!!sy) -
h, 0)) {
502 s->vdsp.emulated_edge_mc(
s->sc.edge_emu_buffer,
src,
503 s->linesize,
s->linesize,
504 w + 1, (
h + 1) << field_based,
505 src_x, src_y * (1 << field_based),
506 h_edge_pos, v_edge_pos);
507 src =
s->sc.edge_emu_buffer;
515 pix_op[op_index](dest,
src,
stride,
h, sx, sy);
527 uint8_t *
const *ref_picture,
529 int motion_x,
int motion_y,
532 const uint8_t *ptr_y, *ptr_cb, *ptr_cr;
533 int mx,
my, src_x, src_y, uvsrc_x, uvsrc_y, sx, sy, uvsx, uvsy;
534 ptrdiff_t uvlinesize, linesize;
535 const int lowres =
s->avctx->lowres;
536 const int op_index =
lowres - 1 +
s->chroma_x_shift;
537 const int block_s = 8 >>
lowres;
538 const int s_mask = (2 <<
lowres) - 1;
539 const int h_edge_pos =
s->h_edge_pos >>
lowres;
540 const int v_edge_pos =
s->v_edge_pos >>
lowres;
541 int hc =
s->chroma_y_shift ? (
h+1-bottom_field)>>1 :
h;
545 linesize =
s->cur_pic.linesize[0] << field_based;
546 uvlinesize =
s->cur_pic.linesize[1] << field_based;
549 if (
s->quarter_sample) {
555 motion_y += (bottom_field - field_select)*((1 <<
lowres)-1);
558 sx = motion_x & s_mask;
559 sy = motion_y & s_mask;
560 src_x =
s->mb_x * 2 * block_s + (motion_x >>
lowres + 1);
561 src_y = (mb_y * 2 * block_s >> field_based) + (motion_y >>
lowres + 1);
564 uvsx = ((motion_x >> 1) & s_mask) | (sx & 1);
565 uvsy = ((motion_y >> 1) & s_mask) | (sy & 1);
566 uvsrc_x = src_x >> 1;
567 uvsrc_y = src_y >> 1;
572 uvsx = (2 *
mx) & s_mask;
573 uvsy = (2 *
my) & s_mask;
574 uvsrc_x =
s->mb_x * block_s + (
mx >>
lowres);
575 uvsrc_y = mb_y * block_s + (
my >>
lowres);
577 if (
s->chroma_y_shift) {
582 uvsrc_x =
s->mb_x * block_s + (
mx >>
lowres + 1);
583 uvsrc_y = (mb_y * block_s >> field_based) + (
my >>
lowres + 1);
585 if (
s->chroma_x_shift) {
589 uvsy = motion_y & s_mask;
591 uvsrc_x =
s->mb_x*block_s + (
mx >> (
lowres+1));
594 uvsx = motion_x & s_mask;
595 uvsy = motion_y & s_mask;
602 ptr_y = ref_picture[0] + src_y * linesize + src_x;
603 ptr_cb = ref_picture[1] + uvsrc_y * uvlinesize + uvsrc_x;
604 ptr_cr = ref_picture[2] + uvsrc_y * uvlinesize + uvsrc_x;
606 if ((
unsigned) src_x >
FFMAX( h_edge_pos - (!!sx) - 2 * block_s, 0) || uvsrc_y<0 ||
607 (
unsigned) src_y >
FFMAX((v_edge_pos >> field_based) - (!!sy) -
FFMAX(
h, field_select + hc<<
s->chroma_y_shift), 0)) {
608 s->vdsp.emulated_edge_mc(
s->sc.edge_emu_buffer, ptr_y,
609 linesize >> field_based, linesize >> field_based,
610 17, 17 + field_based,
611 src_x, src_y * (1 << field_based), h_edge_pos,
613 ptr_y =
s->sc.edge_emu_buffer;
615 uint8_t *ubuf =
s->sc.edge_emu_buffer + 18 *
s->linesize;
616 uint8_t *vbuf =ubuf + 10 *
s->uvlinesize;
618 vbuf -=
s->uvlinesize;
619 s->vdsp.emulated_edge_mc(ubuf, ptr_cb,
620 uvlinesize >> field_based, uvlinesize >> field_based,
622 uvsrc_x, uvsrc_y * (1 << field_based),
623 h_edge_pos >> 1, v_edge_pos >> 1);
624 s->vdsp.emulated_edge_mc(vbuf, ptr_cr,
625 uvlinesize >> field_based,uvlinesize >> field_based,
627 uvsrc_x, uvsrc_y * (1 << field_based),
628 h_edge_pos >> 1, v_edge_pos >> 1);
636 dest_y +=
s->linesize;
637 dest_cb +=
s->uvlinesize;
638 dest_cr +=
s->uvlinesize;
642 ptr_y +=
s->linesize;
643 ptr_cb +=
s->uvlinesize;
644 ptr_cr +=
s->uvlinesize;
649 pix_op[
lowres - 1](dest_y, ptr_y, linesize,
h, sx, sy);
652 uvsx = (uvsx << 2) >> lowres;
653 uvsy = (uvsy << 2) >> lowres;
655 pix_op[op_index](dest_cb, ptr_cb, uvlinesize, hc, uvsx, uvsy);
656 pix_op[op_index](dest_cr, ptr_cr, uvlinesize, hc, uvsx, uvsy);
663 uint8_t *dest_cb, uint8_t *dest_cr,
664 uint8_t *
const *ref_picture,
668 const int lowres =
s->avctx->lowres;
669 const int op_index =
lowres;
670 const int block_s = 8 >>
lowres;
671 const int s_mask = (2 <<
lowres) - 1;
672 const int h_edge_pos =
s->h_edge_pos >>
lowres + 1;
673 const int v_edge_pos =
s->v_edge_pos >>
lowres + 1;
674 int emu = 0, src_x, src_y, sx, sy;
680 if (
s->quarter_sample) {
692 src_x =
s->mb_x * block_s + (
mx >>
lowres + 1);
693 src_y =
s->mb_y * block_s + (
my >>
lowres + 1);
695 offset = src_y *
s->uvlinesize + src_x;
696 ptr = ref_picture[1] +
offset;
697 if ((
unsigned) src_x >
FFMAX(h_edge_pos - (!!sx) - block_s, 0) ||
698 (
unsigned) src_y >
FFMAX(v_edge_pos - (!!sy) - block_s, 0)) {
699 s->vdsp.emulated_edge_mc(
s->sc.edge_emu_buffer, ptr,
700 s->uvlinesize,
s->uvlinesize,
702 src_x, src_y, h_edge_pos, v_edge_pos);
703 ptr =
s->sc.edge_emu_buffer;
708 pix_op[op_index](dest_cb, ptr,
s->uvlinesize, block_s, sx, sy);
710 ptr = ref_picture[2] +
offset;
712 s->vdsp.emulated_edge_mc(
s->sc.edge_emu_buffer, ptr,
713 s->uvlinesize,
s->uvlinesize,
715 src_x, src_y, h_edge_pos, v_edge_pos);
716 ptr =
s->sc.edge_emu_buffer;
718 pix_op[op_index](dest_cr, ptr,
s->uvlinesize, block_s, sx, sy);
733 uint8_t *dest_y, uint8_t *dest_cb,
735 int dir, uint8_t *
const *ref_picture,
740 const int lowres =
s->avctx->lowres;
741 const int block_s = 8 >>
lowres;
746 switch (
s->mv_type) {
751 s->mv[dir][0][0],
s->mv[dir][0][1],
757 for (
int i = 0;
i < 4;
i++) {
759 s->linesize) * block_s,
760 ref_picture[0], 0, 0,
761 (2 * mb_x + (
i & 1)) * block_s,
762 (2 * mb_y + (
i >> 1)) * block_s,
763 s->width,
s->height,
s->linesize,
765 block_s, block_s, pix_op,
766 s->mv[dir][
i][0],
s->mv[dir][
i][1]);
768 mx +=
s->mv[dir][
i][0];
769 my +=
s->mv[dir][
i][1];
780 1, 0,
s->field_select[dir][0],
782 s->mv[dir][0][0],
s->mv[dir][0][1],
786 1, 1,
s->field_select[dir][1],
788 s->mv[dir][1][0],
s->mv[dir][1][1],
791 if (
s->picture_structure !=
s->field_select[dir][0] + 1 &&
793 ref_picture =
s->cur_pic.ptr->f->data;
796 0, 0,
s->field_select[dir][0],
799 s->mv[dir][0][1], 2 * block_s, mb_y >> 1);
803 for (
int i = 0;
i < 2;
i++) {
804 uint8_t *
const *ref2picture;
806 if (
s->picture_structure ==
s->field_select[dir][
i] + 1 ||
808 ref2picture = ref_picture;
810 ref2picture =
s->cur_pic.ptr->f->data;
814 0, 0,
s->field_select[dir][
i],
816 s->mv[dir][
i][0],
s->mv[dir][
i][1] +
817 2 * block_s *
i, block_s, mb_y >> 1);
819 dest_y += 2 * block_s *
s->linesize;
820 dest_cb += (2 * block_s >>
s->chroma_y_shift) *
s->uvlinesize;
821 dest_cr += (2 * block_s >>
s->chroma_y_shift) *
s->uvlinesize;
826 for (
int i = 0;
i < 2;
i++) {
827 for (
int j = 0; j < 2; j++) {
831 s->mv[dir][2 *
i + j][0],
832 s->mv[dir][2 *
i + j][1],
835 pix_op =
s->h264chroma.avg_h264_chroma_pixels_tab;
838 for (
int i = 0;
i < 2;
i++) {
840 0, 0,
s->picture_structure !=
i + 1,
842 s->mv[dir][2 *
i][0],
s->mv[dir][2 *
i][1],
843 2 * block_s, mb_y >> 1);
846 pix_op =
s->h264chroma.avg_h264_chroma_pixels_tab;
850 if (!
s->first_field) {
851 ref_picture =
s->cur_pic.ptr->f->data;
866 int my_max = INT_MIN, my_min = INT_MAX, qpel_shift = !
s->quarter_sample;
872 switch (
s->mv_type) {
886 for (
int i = 0;
i < mvs;
i++) {
887 int my =
s->mv[dir][
i][1];
892 off = ((
FFMAX(-my_min, my_max) << qpel_shift) + 63) >> 6;
894 return av_clip(
s->mb_y + off, 0,
s->mb_height - 1);
896 return s->mb_height - 1;
901 int16_t
block[][64],
int i, uint8_t *dest,
int line_size)
903 if (
s->block_last_index[
i] >= 0) {
904 s->idsp.idct_add(dest, line_size,
block[
i]);
910 int16_t *
block,
int i, uint8_t *dest,
int line_size,
int qscale)
912 s->dct_unquantize_intra(
s,
block,
i, qscale);
913 s->idsp.idct_put(dest, line_size,
block);
917 int16_t
block[][64],
int i, uint8_t *dest,
int line_size,
int qscale)
919 if (
s->block_last_index[
i] >= 0) {
920 s->dct_unquantize_inter(
s,
block[
i],
i, qscale);
922 s->idsp.idct_add(dest, line_size,
block[
i]);
926#define NOT_MPEG12_H261 0
927#define MAY_BE_MPEG12_H261 1
928#define DEFINITELY_MPEG12_H261 2
941 int lowres_flag,
int is_mpeg12)
943#define IS_MPEG12_H261(s) (is_mpeg12 == MAY_BE_MPEG12_H261 ? ((s)->out_format <= FMT_H261) : is_mpeg12)
944 uint8_t *dest_y =
s->dest[0], *dest_cb =
s->dest[1], *dest_cr =
s->dest[2];
945 int dct_linesize, dct_offset;
946 const int linesize =
s->cur_pic.linesize[0];
947 const int uvlinesize =
s->cur_pic.linesize[1];
948 const int block_size = lowres_flag ? 8 >>
s->avctx->lowres : 8;
950 dct_linesize = linesize <<
s->interlaced_dct;
951 dct_offset =
s->interlaced_dct ? linesize : linesize * block_size;
972 op_pix =
s->h264chroma.avg_h264_chroma_pixels_tab;
982 op_pix =
s->hdsp.put_pixels_tab;
983 op_qpix =
s->qdsp.put_qpel_pixels_tab;
985 op_pix =
s->hdsp.put_no_rnd_pixels_tab;
986 op_qpix =
s->qdsp.put_no_rnd_qpel_pixels_tab;
989 ff_mpv_motion(
s, dest_y, dest_cb, dest_cr, 0,
s->last_pic.data, op_pix, op_qpix);
990 op_pix =
s->hdsp.avg_pixels_tab;
991 op_qpix =
s->qdsp.avg_qpel_pixels_tab;
994 ff_mpv_motion(
s, dest_y, dest_cb, dest_cr, 1,
s->next_pic.data, op_pix, op_qpix);
999 if (
s->avctx->skip_idct) {
1027 add_dct(
s,
block, 3, dest_y + dct_offset + block_size, dct_linesize);
1030 if (
s->chroma_y_shift) {
1035 dct_linesize = uvlinesize <<
s->interlaced_dct;
1036 dct_offset =
s->interlaced_dct ? uvlinesize : uvlinesize*block_size;
1042 if (!
s->chroma_x_shift) {
1045 add_dct(
s,
block, 10, dest_cb + block_size + dct_offset, dct_linesize);
1046 add_dct(
s,
block, 11, dest_cr + block_size + dct_offset, dct_linesize);
1050 }
else if (CONFIG_WMV2_DECODER) {
1058 s->avctx->bits_per_raw_sample > 8) {
1060 uvlinesize, dct_linesize, dct_offset);
1064 put_dct(
s,
block[1], 1, dest_y + block_size, dct_linesize,
s->qscale);
1065 put_dct(
s,
block[2], 2, dest_y + dct_offset , dct_linesize,
s->qscale);
1066 put_dct(
s,
block[3], 3, dest_y + dct_offset + block_size, dct_linesize,
s->qscale);
1069 if (
s->chroma_y_shift) {
1075 put_dct(
s,
block[4], 4, dest_cb, dct_linesize,
s->chroma_qscale);
1076 put_dct(
s,
block[5], 5, dest_cr, dct_linesize,
s->chroma_qscale);
1077 put_dct(
s,
block[6], 6, dest_cb + dct_offset, dct_linesize,
s->chroma_qscale);
1078 put_dct(
s,
block[7], 7, dest_cr + dct_offset, dct_linesize,
s->chroma_qscale);
1082 s->idsp.idct_put(dest_y, dct_linesize,
block[0]);
1083 s->idsp.idct_put(dest_y + block_size, dct_linesize,
block[1]);
1084 s->idsp.idct_put(dest_y + dct_offset, dct_linesize,
block[2]);
1085 s->idsp.idct_put(dest_y + dct_offset + block_size, dct_linesize,
block[3]);
1088 if (
s->chroma_y_shift) {
1089 s->idsp.idct_put(dest_cb, uvlinesize,
block[4]);
1090 s->idsp.idct_put(dest_cr, uvlinesize,
block[5]);
1092 dct_linesize = uvlinesize <<
s->interlaced_dct;
1093 dct_offset =
s->interlaced_dct ? uvlinesize : uvlinesize*block_size;
1095 s->idsp.idct_put(dest_cb, dct_linesize,
block[4]);
1096 s->idsp.idct_put(dest_cr, dct_linesize,
block[5]);
1097 s->idsp.idct_put(dest_cb + dct_offset, dct_linesize,
block[6]);
1098 s->idsp.idct_put(dest_cr + dct_offset, dct_linesize,
block[7]);
1099 if (!
s->chroma_x_shift) {
1100 s->idsp.idct_put(dest_cb + block_size, dct_linesize,
block[8]);
1101 s->idsp.idct_put(dest_cr + block_size, dct_linesize,
block[9]);
1102 s->idsp.idct_put(dest_cb + block_size + dct_offset, dct_linesize,
block[10]);
1103 s->idsp.idct_put(dest_cr + block_size + dct_offset, dct_linesize,
block[11]);
1116 void *
const logctx =
s->avctx;
1117 const uint8_t *
const idct_permutation =
s->idsp.idct_permutation;
1121 for (
int i = 0;
i < 6;
i++) {
1122 for (
int j = 0; j < 64; j++) {
1124 block[
i][idct_permutation[j]]);
1132 const int mb_xy =
s->mb_y *
s->mb_stride +
s->mb_x;
1133 uint8_t *mbskip_ptr = &
s->mbskip_table[mb_xy];
1135 s->cur_pic.qscale_table[mb_xy] =
s->qscale;
1138 if (
s->mb_skipped) {
1142 }
else if (!
s->cur_pic.reference) {
1152 if (!
s->avctx->lowres) {
uint8_t ptrdiff_t const uint8_t ptrdiff_t int intptr_t intptr_t my
uint8_t ptrdiff_t const uint8_t ptrdiff_t int intptr_t mx
uint8_t ptrdiff_t const uint8_t ptrdiff_t int intptr_t intptr_t int int16_t * dst
simple assert() macros that are a bit more flexible than ISO C assert().
#define av_assert2(cond)
assert() equivalent, that does lie in speed critical code.
#define av_assert1(cond)
assert() equivalent, that does not lie in speed critical code.
#define av_unreachable(msg)
Asserts that are used as compiler optimization hints depending upon ASSERT_LEVEL and NBDEBUG.
#define av_assert0(cond)
assert() equivalent, that is always enabled.
Libavcodec external API header.
#define FF_THREAD_FRAME
Decode more than one frame at once.
#define FF_DEBUG_DCT_COEFF
#define i(width, name, range_min, range_max)
#define AV_CEIL_RSHIFT(a, b)
enum ThreadingStatus ff_thread_sync_ref(AVCodecContext *avctx, size_t offset)
Allows to synchronize objects whose lifetime is the whole decoding process among all frame threads.
int ff_hwaccel_frame_priv_alloc(AVCodecContext *avctx, void **hwaccel_picture_private)
Allocate a hwaccel frame private data if the provided avctx uses a hwaccel method that needs it.
#define AV_GET_BUFFER_FLAG_REF
The decoder will keep a reference to the frame and may reuse it later.
#define AV_CODEC_FLAG_GRAY
Only decode/encode grayscale.
#define AV_CODEC_EXPORT_DATA_VIDEO_ENC_PARAMS
Decoding only.
int avcodec_default_get_buffer2(AVCodecContext *s, AVFrame *frame, int flags)
The default callback for AVCodecContext.get_buffer2().
@ AVDISCARD_ALL
discard all
@ AVDISCARD_NONKEY
discard all frames except keyframes
@ AVDISCARD_NONREF
discard all non reference
#define AVERROR_BUG
Internal bug, also see AVERROR_BUG2.
#define AV_FRAME_FLAG_INTERLACED
A flag to mark frames whose content is interlaced.
#define AV_FRAME_FLAG_TOP_FIELD_FIRST
A flag to mark frames where the top field is displayed first if the content is interlaced.
#define AV_FRAME_FLAG_KEY
A flag to mark frames that are keyframes.
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
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...
@ AV_PICTURE_TYPE_I
Intra.
@ AV_PICTURE_TYPE_B
Bi-dir predicted.
static int ff_h263_round_chroma(int x)
void ff_put_h264_chroma_mc2_8_c(uint8_t *dst, const uint8_t *src, ptrdiff_t srcStride, int h, int x, int y)
void ff_avg_h264_chroma_mc2_8_c(uint8_t *dst, const uint8_t *src, ptrdiff_t srcStride, int h, int x, int y)
void(* h264_chroma_mc_func)(uint8_t *dst, const uint8_t *src, ptrdiff_t srcStride, int h, int x, int y)
void(* op_pixels_func)(uint8_t *block, const uint8_t *pixels, ptrdiff_t line_size, int h)
Average and put pixel Widths can be 16, 8, 4 or 2.
static int16_t mult(Float11 *f1, Float11 *f2)
av_cold void ff_h264chroma_init(H264ChromaContext *c, int bit_depth)
common internal api header.
unsigned int ff_toupper4(unsigned int x)
Multithreading API for decoders.
@ FF_THREAD_NO_FRAME_THREADING
common internal API header
void ff_mpeg4_decode_studio(MpegEncContext *s, uint8_t *dest_y, uint8_t *dest_cb, uint8_t *dest_cr, int block_size, int uvlinesize, int dct_linesize, int dct_offset)
void ff_mpv_unref_picture(MPVWorkPicture *pic)
void ff_mpv_workpic_from_pic(MPVWorkPicture *wpic, MPVPicture *pic)
int ff_mpv_pic_check_linesize(void *logctx, const AVFrame *f, ptrdiff_t *linesizep, ptrdiff_t *uvlinesizep)
int ff_mpv_alloc_pic_accessories(AVCodecContext *avctx, MPVWorkPicture *wpic, ScratchpadContext *sc, BufferPoolContext *pools, int mb_height)
Allocate an MPVPicture's accessories (but not the AVFrame's buffer itself) and set the MPVWorkPicture...
av_cold AVRefStructPool * ff_mpv_alloc_pic_pool(int init_progress)
Allocate a pool of MPVPictures.
void ff_mpv_replace_picture(MPVWorkPicture *dst, const MPVWorkPicture *src)
void ff_print_debug_info2(AVCodecContext *avctx, AVFrame *pict, const uint32_t *mbtype_table, const int8_t *qscale_table, int16_t(*const motion_val[2])[2], int mb_width, int mb_height, int mb_stride, int quarter_sample)
Print debugging info for the given picture.
void ff_draw_horiz_band(AVCodecContext *avctx, const AVFrame *cur, const AVFrame *last, int y, int h, int picture_structure, int first_field, int low_delay)
Draw a horizontal band if supported.
av_cold void ff_mpv_free_context_frame(MpegEncContext *s)
Frees and resets MpegEncContext fields depending on the resolution as well as the slice thread contex...
av_cold int ff_mpv_init_duplicate_contexts(MpegEncContext *s)
Initialize an MpegEncContext's thread contexts.
av_cold void ff_mpv_idct_init(MpegEncContext *s)
av_cold void ff_mpv_common_end(MpegEncContext *s)
av_cold int ff_mpv_init_context_frame(MpegEncContext *s)
Initialize and allocates MpegEncContext fields dependent on the resolution.
av_cold void ff_mpv_common_defaults(MpegEncContext *s)
Set the given MpegEncContext to common defaults (same for encoding and decoding).
void ff_mpv_motion(MpegEncContext *s, uint8_t *dest_y, uint8_t *dest_cb, uint8_t *dest_cr, int dir, uint8_t *const *ref_picture, const op_pixels_func(*pix_op)[4], const qpel_mc_func(*qpix_op)[16])
#define MV_TYPE_16X8
2 vectors, one per 16x8 block
#define MV_TYPE_DMV
2 vectors, special mpeg2 Dual Prime Vectors
#define MV_TYPE_FIELD
2 vectors, one per field
#define MV_TYPE_8X8
4 vectors (H.263, MPEG-4 4MV)
#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.
av_cold void ff_mpeg_flush(AVCodecContext *avctx)
static void put_dct(MpegEncContext *s, int16_t *block, int i, uint8_t *dest, int line_size, int qscale)
void ff_mpv_frame_end(MpegEncContext *s)
#define MAY_BE_MPEG12_H261
int ff_mpv_export_qp_table(const MpegEncContext *s, AVFrame *f, const MPVPicture *p, int qp_type)
int ff_mpv_alloc_dummy_frames(MpegEncContext *s)
Ensure that the dummy frames are allocated according to pict_type if necessary.
#define DEFINITELY_MPEG12_H261
void ff_print_debug_info(const MpegEncContext *s, const MPVPicture *p, AVFrame *pict)
av_cold int ff_mpv_decode_close(AVCodecContext *avctx)
static int av_cold alloc_dummy_frame(MpegEncContext *s, MPVWorkPicture *dst)
static int lowest_referenced_row(MpegEncContext *s, int dir)
find the lowest MB row referenced in the MVs
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.
static int hpel_motion_lowres(MpegEncContext *s, uint8_t *dest, const uint8_t *src, int field_based, int field_select, int src_x, int src_y, int width, int height, ptrdiff_t stride, int h_edge_pos, int v_edge_pos, int w, int h, const h264_chroma_mc_func *pix_op, int motion_x, int motion_y)
static int alloc_picture(MpegEncContext *s, MPVWorkPicture *dst, int reference)
#define H264_CHROMA_MC(OPNAME, OP)
static void MPV_motion_lowres(MpegEncContext *s, uint8_t *dest_y, uint8_t *dest_cb, uint8_t *dest_cr, int dir, uint8_t *const *ref_picture, const h264_chroma_mc_func *pix_op)
motion compensation of a single macroblock
static void add_dequant_dct(MpegEncContext *s, int16_t block[][64], int i, uint8_t *dest, int line_size, int qscale)
int ff_mpeg_update_thread_context(AVCodecContext *dst, const AVCodecContext *src)
update_thread_context for mpegvideo-based decoders.
void ff_mpeg_draw_horiz_band(MpegEncContext *s, int y, int h)
static av_always_inline void mpeg_motion_lowres(MpegEncContext *s, uint8_t *dest_y, uint8_t *dest_cb, uint8_t *dest_cr, int field_based, int bottom_field, int field_select, uint8_t *const *ref_picture, const h264_chroma_mc_func *pix_op, int motion_x, int motion_y, int h, int mb_y)
static void color_frame(AVFrame *frame, int luma)
static void add_dct(MpegEncContext *s, int16_t block[][64], int i, uint8_t *dest, int line_size)
#define IS_MPEG12_H261(s)
static void chroma_4mv_motion_lowres(MpegEncContext *s, uint8_t *dest_cb, uint8_t *dest_cr, uint8_t *const *ref_picture, const h264_chroma_mc_func *pix_op, int mx, int my)
av_cold int ff_mpv_common_frame_size_change(MpegEncContext *s)
static av_always_inline void mpv_reconstruct_mb_internal(MpegEncContext *s, int16_t block[12][64], int lowres_flag, int is_mpeg12)
static av_cold void debug_dct_coeffs(MPVContext *s, const int16_t block[][64])
mpegvideo decoder header.
#define FF_MPV_QSCALE_TYPE_MPEG1
int av_pix_fmt_get_chroma_sub_sample(enum AVPixelFormat pix_fmt, int *h_shift, int *v_shift)
Utility function to access log2_chroma_w log2_chroma_h from the pixel format AVPixFmtDescriptor.
int ff_thread_get_buffer(AVCodecContext *avctx, AVFrame *f, int flags)
Wrapper around get_buffer() for frame-multithreaded codecs.
int ff_thread_can_start_frame(AVCodecContext *avctx)
void(* qpel_mc_func)(uint8_t *dst, const uint8_t *src, ptrdiff_t stride)
void * av_refstruct_pool_get(AVRefStructPool *pool)
Get an object from the pool, reusing an old one from the pool when available.
static void av_refstruct_pool_uninit(AVRefStructPool **poolp)
Mark the pool as being available for freeing.
main external API structure.
enum AVPixelFormat pix_fmt
Pixel format, see AV_PIX_FMT_xxx.
int width
picture width / height.
const struct AVHWAccel * hwaccel
Hardware accelerator in use.
This structure describes decoded (raw) audio or video data.
int format
format of the frame, -1 if unknown or unset Values correspond to enum AVPixelFormat for video frames,...
Data structure for storing block-level encoding information.
Video encoding parameters for a given frame.
int dummy
Picture is a dummy and should not be output.
void * hwaccel_picture_private
RefStruct reference for hardware accelerator private data.
int workaround_bugs
workaround bugs in encoders which cannot be detected automatically
int first_field
is 1 for the first field of a field picture 0 otherwise
uint16_t pb_field_time
like above, just for interlaced
MPVWorkPicture next_pic
copy of the next picture structure.
MPVWorkPicture last_pic
copy of the previous picture structure.
int quarter_sample
1->qpel, 0->half pel ME/MC
int low_delay
no reordering needed / has no B-frames
int height
picture size. must be a multiple of 16
ptrdiff_t linesize
line size, in bytes, may be different from width
MPVWorkPicture cur_pic
copy of the current picture structure.
ptrdiff_t uvlinesize
line size, for chroma in bytes, may be different from width
void ff_thread_progress_report(ThreadProgress *pro, int n)
This function is a no-op in no-op mode; otherwise it notifies other threads that a certain level of p...
void ff_thread_progress_await(const ThreadProgress *pro_c, int n)
This function is a no-op in no-op mode; otherwise it waits until other threads have reached a certain...
AVVideoEncParams * av_video_enc_params_create_side_data(AVFrame *frame, enum AVVideoEncParamsType type, unsigned int nb_blocks)
Allocates memory for AVEncodeInfoFrame plus an array of nb_blocks AVEncodeInfoBlock in the given AVFr...
static av_always_inline AVVideoBlockParams * av_video_enc_params_block(AVVideoEncParams *par, unsigned int idx)
Get the block at the specified idx.
@ AV_VIDEO_ENC_PARAMS_MPEG2
void ff_wmv2_add_mb(MpegEncContext *s, int16_t block1[6][64], uint8_t *dest_y, uint8_t *dest_cb, uint8_t *dest_cr)