FFmpeg
parser_internal.h
Go to the documentation of this file.
1 /*
2  * This file is part of FFmpeg.
3  *
4  * FFmpeg is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2.1 of the License, or (at your option) any later version.
8  *
9  * FFmpeg is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with FFmpeg; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17  */
18 
19 #ifndef AVCODEC_PARSER_INTERNAL_H
20 #define AVCODEC_PARSER_INTERNAL_H
21 
22 #include <stdint.h>
23 
24 #include "libavutil/macros.h"
25 #include "avcodec.h"
26 #include "codec_id.h"
27 
28 #if FF_API_PARSER_PRIVATE
29 typedef union FFCodecParser {
30  struct {
31 #if FF_API_PARSER_CODECID
32  int codec_ids[7]; /* several codec IDs are permitted */
33 #else
34  enum AVCodecID codec_ids[7]; /* several codec IDs are permitted */
35 #endif
39  AVCodecContext *avctx,
40  const uint8_t **poutbuf, int *poutbuf_size,
41  const uint8_t *buf, int buf_size);
43  int (*split)(AVCodecContext *avctx, const uint8_t *buf, int buf_size);
44  };
46 #else
47 typedef struct FFCodecParser {
49  unsigned priv_data_size;
50  int (*init)(AVCodecParserContext *s);
52  AVCodecContext *avctx,
53  const uint8_t **poutbuf, int *poutbuf_size,
54  const uint8_t *buf, int buf_size);
55  void (*close)(AVCodecParserContext *s);
56 #endif
58 
59 static inline const FFCodecParser *ffcodecparser(const AVCodecParser *parser)
60 {
61  return (const FFCodecParser*)parser;
62 }
63 
64 #define EIGTH_ARG(a,b,c,d,e,f,g,h,...) h
65 #define NO_FAIL
66 // Expands to nothing if <= 7 args; induces compilation failure if not.
67 #define CHECK_FOR_TOO_MANY_IDS(...) AV_JOIN(EIGTH_ARG(__VA_ARGS__, NO, NO, NO, NO, NO, NO, NO, NO), _FAIL)
68 
69 // For compatibility with MSVC's old, spec-incompliant preprocessor.
70 #define FF_MSVC_EXPAND(...) __VA_ARGS__
71 #define FIRST_SEVEN2(a,b,c,d,e,f,g,...) a,b,c,d,e,f,g
72 #define FIRST_SEVEN(...) FF_MSVC_EXPAND(FIRST_SEVEN2(__VA_ARGS__))
73 #define TIMES_SEVEN(a) a,a,a,a,a,a,a
74 
75 #if FF_API_PARSER_PRIVATE
76 #define PARSER_CODEC_LIST(...) CHECK_FOR_TOO_MANY_IDS(__VA_ARGS__) \
77  .codec_ids = { FIRST_SEVEN(__VA_ARGS__, TIMES_SEVEN(AV_CODEC_ID_NONE)) }
78 #else
79 #define PARSER_CODEC_LIST(...) CHECK_FOR_TOO_MANY_IDS(__VA_ARGS__) \
80  .p.codec_ids = { FIRST_SEVEN(__VA_ARGS__, TIMES_SEVEN(AV_CODEC_ID_NONE)) }
81 #endif
82 
83 #endif /* AVCODEC_PARSER_INTERNAL_H */
FFCodecParser::parse
int(* parse)(AVCodecParserContext *s, AVCodecContext *avctx, const uint8_t **poutbuf, int *poutbuf_size, const uint8_t *buf, int buf_size)
Definition: parser_internal.h:38
macros.h
FFCodecParser::codec_ids
int codec_ids[7]
Definition: parser_internal.h:32
ffcodecparser
static const FFCodecParser * ffcodecparser(const AVCodecParser *parser)
Definition: parser_internal.h:59
codec_id.h
s
#define s(width, name)
Definition: cbs_vp9.c:198
FFCodecParser::split
int(* split)(AVCodecContext *avctx, const uint8_t *buf, int buf_size)
Definition: parser_internal.h:43
FFCodecParser::close
void(* close)(AVCodecParserContext *s)
Definition: parser_internal.h:42
FFCodecParser::priv_data_size
int priv_data_size
Definition: parser_internal.h:36
AVCodecID
AVCodecID
Identify the syntax and semantics of the bitstream.
Definition: codec_id.h:49
FFCodecParser
Definition: parser_internal.h:29
FFCodecParser::init
int(* init)(AVCodecParserContext *s)
Definition: parser_internal.h:37
avcodec.h
AVCodecParserContext
Definition: avcodec.h:2575
AVCodecContext
main external API structure.
Definition: avcodec.h:431
AVCodecParser
Definition: avcodec.h:2734
FFCodecParser::p
AVCodecParser p
Definition: parser_internal.h:45