FFmpeg
Loading...
Searching...
No Matches
mpegutils.h
Go to the documentation of this file.
1/*
2 * Mpeg video formats-related defines and utility functions
3 *
4 * This file is part of FFmpeg.
5 *
6 * FFmpeg is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
10 *
11 * FFmpeg is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with FFmpeg; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19 */
20
21#ifndef AVCODEC_MPEGUTILS_H
22#define AVCODEC_MPEGUTILS_H
23
24#include <stdint.h>
25
26#include "libavutil/frame.h"
27
28#include "avcodec.h"
29
30/* picture type */
31#define PICT_TOP_FIELD 1
32#define PICT_BOTTOM_FIELD 2
33#define PICT_FRAME 3
34
35#define MAX_MB_BYTES (30 * 16 * 16 * 3 / 8 + 120)
36
37/* MB types */
38#define MB_TYPE_INTRA4x4 (1 << 0)
39#define MB_TYPE_INTRA16x16 (1 << 1) // FIXME H.264-specific
40#define MB_TYPE_INTRA_PCM (1 << 2) // FIXME H.264-specific
41#define MB_TYPE_16x16 (1 << 3)
42#define MB_TYPE_16x8 (1 << 4)
43#define MB_TYPE_8x16 (1 << 5)
44#define MB_TYPE_8x8 (1 << 6)
45#define MB_TYPE_INTERLACED (1 << 7)
46#define MB_TYPE_DIRECT2 (1 << 8) // FIXME
47#define MB_TYPE_CBP (1 << 10)
48#define MB_TYPE_QUANT (1 << 11)
49#define MB_TYPE_FORWARD_MV (1 << 12)
50#define MB_TYPE_BACKWARD_MV (1 << 13)
51#define MB_TYPE_BIDIR_MV (MB_TYPE_FORWARD_MV | MB_TYPE_BACKWARD_MV)
52// MB_TYPE_P[01]L[01], MB_TYPE_L[01] and MB_TYPE_L0L1 are H.264 only.
53#define MB_TYPE_P0L0 (1 << 12)
54#define MB_TYPE_P1L0 (1 << 13)
55#define MB_TYPE_P0L1 (1 << 14)
56#define MB_TYPE_P1L1 (1 << 15)
57#define MB_TYPE_L0 (MB_TYPE_P0L0 | MB_TYPE_P1L0)
58#define MB_TYPE_L1 (MB_TYPE_P0L1 | MB_TYPE_P1L1)
59#define MB_TYPE_L0L1 (MB_TYPE_L0 | MB_TYPE_L1)
60#define MB_TYPE_GMC (1 << 16)
61#define MB_TYPE_SKIP (1 << 17)
62#define MB_TYPE_ACPRED (1 << 18)
63
64#define MB_TYPE_INTRA MB_TYPE_INTRA4x4 // default mb_type if there is just one type
65
66// The following MB-type can be used by each codec as it sees fit.
67#define MB_TYPE_CODEC_SPECIFIC (1 << 9)
68
69#define IS_INTRA4x4(a) ((a) & MB_TYPE_INTRA4x4)
70#define IS_INTRA16x16(a) ((a) & MB_TYPE_INTRA16x16)
71#define IS_PCM(a) ((a) & MB_TYPE_INTRA_PCM)
72#define IS_INTRA(a) ((a) & 7)
73#define IS_INTER(a) ((a) & (MB_TYPE_16x16 | MB_TYPE_16x8 | \
74 MB_TYPE_8x16 | MB_TYPE_8x8))
75#define IS_SKIP(a) ((a) & MB_TYPE_SKIP)
76#define IS_INTRA_PCM(a) ((a) & MB_TYPE_INTRA_PCM)
77#define IS_INTERLACED(a) ((a) & MB_TYPE_INTERLACED)
78#define IS_DIRECT(a) ((a) & MB_TYPE_DIRECT2)
79#define IS_GMC(a) ((a) & MB_TYPE_GMC)
80#define IS_16X16(a) ((a) & MB_TYPE_16x16)
81#define IS_16X8(a) ((a) & MB_TYPE_16x8)
82#define IS_8X16(a) ((a) & MB_TYPE_8x16)
83#define IS_8X8(a) ((a) & MB_TYPE_8x8)
84#define IS_ACPRED(a) ((a) & MB_TYPE_ACPRED)
85#define IS_QUANT(a) ((a) & MB_TYPE_QUANT)
86
87#define HAS_CBP(a) ((a) & MB_TYPE_CBP)
88#define HAS_FORWARD_MV(a) ((a) & MB_TYPE_FORWARD_MV)
89#define HAS_BACKWARD_MV(a) ((a) & MB_TYPE_BACKWARD_MV)
90// dir == 0 means forward, dir == 1 is backward
91#define HAS_MV(a, dir) ((a) & (MB_TYPE_FORWARD_MV << (dir)))
92
93#define MB_TYPE_MV_2_MV_DIR(a) (((a) >> 12) & (MV_DIR_FORWARD | MV_DIR_BACKWARD))
94
95/**
96 * Draw a horizontal band if supported.
97 *
98 * @param h is the normal height, this will be reduced automatically if needed
99 */
100void ff_draw_horiz_band(AVCodecContext *avctx, const AVFrame *cur, const AVFrame *last,
101 int y, int h, int picture_structure, int first_field,
102 int low_delay);
103
104/**
105 * Print debugging info for the given picture.
106 */
108 const uint32_t *mbtype_table,
109 const int8_t *qscale_table, int16_t (*const motion_val[2])[2],
110 int mb_width, int mb_height, int mb_stride, int quarter_sample);
111
112#endif /* AVCODEC_MPEGUTILS_H */
Libavcodec external API header.
reference-counted frame API
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.
Definition mpegutils.c:155
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.
Definition mpegutils.c:54
main external API structure.
Definition avcodec.h:443
This structure describes decoded (raw) audio or video data.
Definition frame.h:472
static int first_field(const struct video_data *s)
Definition v4l2.c:260