]> git.sesse.net Git - ffmpeg/blob - libavcodec/mpegutils.h
DirectDraw Surface image decoder
[ffmpeg] / libavcodec / mpegutils.h
1 /*
2  * Mpeg video formats-related defines and utility functions
3  *
4  * This file is part of Libav.
5  *
6  * Libav 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  * Libav 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 Libav; 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 #include "version.h"
30
31
32 /* picture type */
33 #define PICT_TOP_FIELD     1
34 #define PICT_BOTTOM_FIELD  2
35 #define PICT_FRAME         3
36
37 /**
38  * Value of Picture.reference when Picture is not a reference picture, but
39  * is held for delayed output.
40  */
41 #define DELAYED_PIC_REF 4
42
43
44 /* MB types */
45 #if !FF_API_MB_TYPE
46 #define MB_TYPE_INTRA4x4   (1 <<  0)
47 #define MB_TYPE_INTRA16x16 (1 <<  1) // FIXME H.264-specific
48 #define MB_TYPE_INTRA_PCM  (1 <<  2) // FIXME H.264-specific
49 #define MB_TYPE_16x16      (1 <<  3)
50 #define MB_TYPE_16x8       (1 <<  4)
51 #define MB_TYPE_8x16       (1 <<  5)
52 #define MB_TYPE_8x8        (1 <<  6)
53 #define MB_TYPE_INTERLACED (1 <<  7)
54 #define MB_TYPE_DIRECT2    (1 <<  8) // FIXME
55 #define MB_TYPE_ACPRED     (1 <<  9)
56 #define MB_TYPE_GMC        (1 << 10)
57 #define MB_TYPE_SKIP       (1 << 11)
58 #define MB_TYPE_P0L0       (1 << 12)
59 #define MB_TYPE_P1L0       (1 << 13)
60 #define MB_TYPE_P0L1       (1 << 14)
61 #define MB_TYPE_P1L1       (1 << 15)
62 #define MB_TYPE_L0         (MB_TYPE_P0L0 | MB_TYPE_P1L0)
63 #define MB_TYPE_L1         (MB_TYPE_P0L1 | MB_TYPE_P1L1)
64 #define MB_TYPE_L0L1       (MB_TYPE_L0   | MB_TYPE_L1)
65 #define MB_TYPE_QUANT      (1 << 16)
66 #define MB_TYPE_CBP        (1 << 17)
67 #endif
68
69 #define MB_TYPE_INTRA    MB_TYPE_INTRA4x4 // default mb_type if there is just one type
70
71 #define IS_INTRA4x4(a)   ((a) & MB_TYPE_INTRA4x4)
72 #define IS_INTRA16x16(a) ((a) & MB_TYPE_INTRA16x16)
73 #define IS_PCM(a)        ((a) & MB_TYPE_INTRA_PCM)
74 #define IS_INTRA(a)      ((a) & 7)
75 #define IS_INTER(a)      ((a) & (MB_TYPE_16x16 | MB_TYPE_16x8 | \
76                                  MB_TYPE_8x16  | MB_TYPE_8x8))
77 #define IS_SKIP(a)       ((a) & MB_TYPE_SKIP)
78 #define IS_INTRA_PCM(a)  ((a) & MB_TYPE_INTRA_PCM)
79 #define IS_INTERLACED(a) ((a) & MB_TYPE_INTERLACED)
80 #define IS_DIRECT(a)     ((a) & MB_TYPE_DIRECT2)
81 #define IS_GMC(a)        ((a) & MB_TYPE_GMC)
82 #define IS_16X16(a)      ((a) & MB_TYPE_16x16)
83 #define IS_16X8(a)       ((a) & MB_TYPE_16x8)
84 #define IS_8X16(a)       ((a) & MB_TYPE_8x16)
85 #define IS_8X8(a)        ((a) & MB_TYPE_8x8)
86 #define IS_SUB_8X8(a)    ((a) & MB_TYPE_16x16) // note reused
87 #define IS_SUB_8X4(a)    ((a) & MB_TYPE_16x8)  // note reused
88 #define IS_SUB_4X8(a)    ((a) & MB_TYPE_8x16)  // note reused
89 #define IS_SUB_4X4(a)    ((a) & MB_TYPE_8x8)   // note reused
90 #define IS_ACPRED(a)     ((a) & MB_TYPE_ACPRED)
91 #define IS_QUANT(a)      ((a) & MB_TYPE_QUANT)
92 #define IS_DIR(a, part, list) ((a) & (MB_TYPE_P0L0 << ((part) + 2 * (list))))
93
94 // does this mb use listX, note does not work if subMBs
95 #define USES_LIST(a, list) ((a) & ((MB_TYPE_P0L0 | MB_TYPE_P1L0) << (2 * (list))))
96
97 #define HAS_CBP(a)       ((a) & MB_TYPE_CBP)
98
99 /* MB types for encoding */
100 #define CANDIDATE_MB_TYPE_INTRA      (1 <<  0)
101 #define CANDIDATE_MB_TYPE_INTER      (1 <<  1)
102 #define CANDIDATE_MB_TYPE_INTER4V    (1 <<  2)
103 #define CANDIDATE_MB_TYPE_SKIPPED    (1 <<  3)
104
105 #define CANDIDATE_MB_TYPE_DIRECT     (1 <<  4)
106 #define CANDIDATE_MB_TYPE_FORWARD    (1 <<  5)
107 #define CANDIDATE_MB_TYPE_BACKWARD   (1 <<  6)
108 #define CANDIDATE_MB_TYPE_BIDIR      (1 <<  7)
109
110 #define CANDIDATE_MB_TYPE_INTER_I    (1 <<  8)
111 #define CANDIDATE_MB_TYPE_FORWARD_I  (1 <<  9)
112 #define CANDIDATE_MB_TYPE_BACKWARD_I (1 << 10)
113 #define CANDIDATE_MB_TYPE_BIDIR_I    (1 << 11)
114
115 #define CANDIDATE_MB_TYPE_DIRECT0    (1 << 12)
116
117
118 enum OutputFormat {
119     FMT_MPEG1,
120     FMT_H261,
121     FMT_H263,
122     FMT_MJPEG,
123 };
124
125
126 /**
127  * Draw a horizontal band if supported.
128  *
129  * @param h is the normal height, this will be reduced automatically if needed
130  */
131 void ff_draw_horiz_band(AVCodecContext *avctx, AVFrame *cur, AVFrame *last,
132                         int y, int h, int picture_structure, int first_field,
133                         int low_delay);
134
135 #endif /* AVCODEC_PICTTYPE_H */