1 /*
2 * DNxHD/VC-3 parser
3 * Copyright (c) 2008 Baptiste Coudurier <baptiste.coudurier@free.fr>
4 *
5 * This file is part of FFmpeg.
6 *
7 * FFmpeg is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
11 *
12 * FFmpeg is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with FFmpeg; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 */
21
22 /**
23 * @file
24 * DNxHD/VC-3 parser
25 */
26
29
36
39 {
43 int i = 0;
44
45 if (!pic_found) {
46 for (i = 0; i < buf_size; i++) {
47 state = (state << 8) | buf[i];
49 i++;
50 pic_found = 1;
53 break;
54 }
55 }
56 }
57
59 if (!buf_size) /* EOF considered as end of frame */
60 return 0;
61 for (; i < buf_size; i++) {
63 state = (state << 8) | buf[i];
64
66 dctx->
h = (state >> 32) & 0xFFFF;
68 dctx->
w = (state >> 32) & 0xFFFF;
70 int cid = (state >> 32) & 0xFFFFFFFF;
71 int remaining;
72
73 if (cid <= 0)
74 continue;
75
77 if (remaining <= 0) {
79 if (remaining <= 0)
80 continue;
81 }
83 if (buf_size - i + 47 >= dctx->
remaining) {
85
90 return remaining;
91 } else {
93 }
94 }
95 }
96 } else if (pic_found) {
99 } else {
101
106 return remaining;
107 }
108 }
112 }
113
116 const uint8_t **poutbuf,
int *poutbuf_size,
118 {
121 int next;
122
124 next = buf_size;
125 } else {
129 *poutbuf_size = 0;
130 return buf_size;
131 }
132 }
134 *poutbuf_size = buf_size;
135 return next;
136 }
137
143 };
static av_always_inline uint64_t ff_dnxhd_check_header_prefix(uint64_t prefix)
static int dnxhd_parse(AVCodecParserContext *s, AVCodecContext *avctx, const uint8_t **poutbuf, int *poutbuf_size, const uint8_t *buf, int buf_size)
int avpriv_dnxhd_get_frame_size(int cid)
int ff_combine_frame(ParseContext *pc, int next, const uint8_t **buf, int *buf_size)
Combine the (truncated) bitstream to a complete frame.
AVCodecParser ff_dnxhd_parser
void ff_parse_close(AVCodecParserContext *s)
static int dnxhd_find_frame_end(DNXHDParserContext *dctx, const uint8_t *buf, int buf_size)
static av_always_inline int ff_dnxhd_get_hr_frame_size(int cid, int w, int h)
main external API structure.
uint64_t state64
contains the last 8 bytes in MSB order
#define PARSER_FLAG_COMPLETE_FRAMES