36 int motion_x,
int motion_y,
int motion_scale,
41 mb->motion_x = motion_x;
42 mb->motion_y = motion_y;
43 mb->motion_scale = motion_scale;
46 mb->src_x = dst_x + motion_x / motion_scale;
47 mb->src_y = dst_y + motion_y / motion_scale;
48 mb->source = direction ? 1 : -1;
55 int y,
int h,
int picture_structure,
58 const int field_pic = picture_structure !=
PICT_FRAME;
94 y, picture_structure,
h);
97#define HAS_MV_EXT(mb_type, flags, dir) ((mb_type) & flags[(dir)])
120 else if (!
HAS_MV_EXT(mb_type, 1, mb_type_mv_flags))
122 else if (!
HAS_MV_EXT(mb_type, 0, mb_type_mv_flags))
153 const uint32_t *mbtype_table,
154 const int8_t *qscale_table, int16_t (*
const motion_val[2])[2],
155 int mb_width,
int mb_height,
int mb_stride,
int quarter_sample)
162 const int shift = 1 + quarter_sample;
164 const int mv_sample_log2 = is_h264 ? 2 : 1;
165 const int mv_stride = (mb_width << mv_sample_log2) + !is_h264;
166 int mb_x, mb_y, mbcount = 0;
174 for (mb_y = 0; mb_y < mb_height; mb_y++) {
175 for (mb_x = 0; mb_x < mb_width; mb_x++) {
176 int i, direction, mb_type = mbtype_table[mb_x + mb_y * mb_stride];
177 for (direction = 0; direction < 2; direction++) {
178 if (!
HAS_MV_EXT(mb_type, direction, mb_type_mv_flags))
181 for (
i = 0;
i < 4;
i++) {
182 int sx = mb_x * 16 + 4 + 8 * (
i & 1);
183 int sy = mb_y * 16 + 4 + 8 * (
i >> 1);
184 int xy = (mb_x * 2 + (
i & 1) +
185 (mb_y * 2 + (
i >> 1)) * mv_stride) << (mv_sample_log2 - 1);
186 int mx = motion_val[direction][xy][0];
187 int my = motion_val[direction][xy][1];
188 mbcount +=
add_mb(mvs + mbcount, mb_type, sx, sy,
mx,
my,
scale, direction);
191 for (
i = 0;
i < 2;
i++) {
192 int sx = mb_x * 16 + 8;
193 int sy = mb_y * 16 + 4 + 8 *
i;
194 int xy = (mb_x * 2 + (mb_y * 2 +
i) * mv_stride) << (mv_sample_log2 - 1);
195 int mx = motion_val[direction][xy][0];
196 int my = motion_val[direction][xy][1];
201 mbcount +=
add_mb(mvs + mbcount, mb_type, sx, sy,
mx,
my,
scale, direction);
204 for (
i = 0;
i < 2;
i++) {
205 int sx = mb_x * 16 + 4 + 8 *
i;
206 int sy = mb_y * 16 + 8;
207 int xy = (mb_x * 2 +
i + mb_y * 2 * mv_stride) << (mv_sample_log2 - 1);
208 int mx = motion_val[direction][xy][0];
209 int my = motion_val[direction][xy][1];
214 mbcount +=
add_mb(mvs + mbcount, mb_type, sx, sy,
mx,
my,
scale, direction);
217 int sx = mb_x * 16 + 8;
218 int sy = mb_y * 16 + 8;
219 int xy = (mb_x + mb_y * mv_stride) << mv_sample_log2;
220 int mx = motion_val[direction][xy][0];
221 int my = motion_val[direction][xy][1];
222 mbcount +=
add_mb(mvs + mbcount, mb_type, sx, sy,
mx,
my,
scale, direction);
244 if (avctx->
hwaccel || !mbtype_table)
271 x_step = (mb_width * 16 > 999) ? 8 : 4;
272 for (x = 0; x < mb_width; x += x_step)
277 for (y = 0; y < mb_height; y++) {
279 for (x = 0; x < mb_width; x++) {
281 av_bprintf(&buf,
"%*d ", margin_left - 1, y << 4);
283 av_bprintf(&buf,
"%2d", qscale_table[x + y * mb_stride]);
286 int mb_type = mbtype_table[x + y * mb_stride];
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
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.
Libavcodec external API header.
#define SLICE_FLAG_ALLOW_FIELD
allow draw_horiz_band() with field slices (MPEG-2 field pics)
#define SLICE_FLAG_CODED_ORDER
draw_horiz_band() is called in coded order instead of display
void av_bprintf(AVBPrint *buf, const char *fmt,...)
void av_bprint_init(AVBPrint *buf, unsigned size_init, unsigned size_max)
#define AV_BPRINT_SIZE_UNLIMITED
#define i(width, name, range_min, range_max)
common internal and external API header
reference-counted frame API
#define AV_NUM_DATA_POINTERS
#define AV_CODEC_EXPORT_DATA_MVS
Export motion vectors through frame side data.
int av_bprint_finalize(AVBPrint *buf, char **ret_str)
Finalize a print buffer.
void av_bprint_chars(AVBPrint *buf, char c, unsigned n)
Append char c n times to a print buffer.
void av_bprint_clear(AVBPrint *buf)
Reset the string to "" but keep internal allocated data.
AVFrameSideData * av_frame_new_side_data(AVFrame *frame, enum AVFrameSideDataType type, size_t size)
Add a new side data to a frame.
@ AV_FRAME_DATA_MOTION_VECTORS
Motion vectors exported by some codecs (on demand through the export_mvs flag set in the libavcodec A...
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
char av_get_picture_type_char(enum AVPictureType pict_type)
Return a single letter to describe the given picture type pict_type.
@ AV_PICTURE_TYPE_B
Bi-dir predicted.
static av_always_inline void scale(vec_s32 res[4], vec_s16 res_packed[2], const int shift)
static int shift(int a, int b)
Memory handling functions.
static char get_segmentation_char(int mb_type)
#define HAS_MV_EXT(mb_type, flags, dir)
static char get_type_mv_char(int mb_type, const int mb_type_mv_flags[2])
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.
static char get_interlacement_char(int mb_type)
static int add_mb(AVMotionVector *mb, uint32_t mb_type, int dst_x, int dst_y, int motion_x, int motion_y, int motion_scale, int direction)
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.
#define MB_TYPE_BACKWARD_MV
#define MB_TYPE_FORWARD_MV
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
main external API structure.
enum AVPixelFormat pix_fmt
Pixel format, see AV_PIX_FMT_xxx.
int slice_flags
slice flags
int64_t frame_num
Frame counter, set by libavcodec.
const struct AVHWAccel * hwaccel
Hardware accelerator in use.
void(* draw_horiz_band)(struct AVCodecContext *s, const AVFrame *src, int offset[AV_NUM_DATA_POINTERS], int y, int type, int height)
If non NULL, 'draw_horiz_band' is called by the libavcodec decoder to draw a horizontal band.
int export_side_data
Bit set of AV_CODEC_EXPORT_DATA_* flags, which affects the kind of metadata exported in frame,...
Structure to hold side data for an AVFrame.
This structure describes decoded (raw) audio or video data.
enum AVPictureType pict_type
Picture type of the frame.
Descriptor that unambiguously describes how the bits of a pixel are stored in the up to 4 data planes...
#define av_malloc_array(a, b)
static int first_field(const struct video_data *s)