ffmpeg / libavcodec / crystalhd.c @ bfde0f1b
History | View | Annotate | Download (35.6 KB)
1 |
/*
|
---|---|
2 |
* - CrystalHD decoder module -
|
3 |
*
|
4 |
* Copyright(C) 2010,2011 Philip Langdale <ffmpeg.philipl@overt.org>
|
5 |
*
|
6 |
* This file is part of FFmpeg.
|
7 |
*
|
8 |
* FFmpeg is free software; you can redistribute it and/or
|
9 |
* modify it under the terms of the GNU Lesser General Public
|
10 |
* License as published by the Free Software Foundation; either
|
11 |
* version 2.1 of the License, or (at your option) any later version.
|
12 |
*
|
13 |
* FFmpeg is distributed in the hope that it will be useful,
|
14 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
15 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
16 |
* Lesser General Public License for more details.
|
17 |
*
|
18 |
* You should have received a copy of the GNU Lesser General Public
|
19 |
* License along with FFmpeg; if not, write to the Free Software
|
20 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
21 |
*/
|
22 |
|
23 |
/*
|
24 |
* - Principles of Operation -
|
25 |
*
|
26 |
* The CrystalHD decoder operates at the bitstream level - which is an even
|
27 |
* higher level than the decoding hardware you typically see in modern GPUs.
|
28 |
* This means it has a very simple interface, in principle. You feed demuxed
|
29 |
* packets in one end and get decoded picture (fields/frames) out the other.
|
30 |
*
|
31 |
* Of course, nothing is ever that simple. Due, at the very least, to b-frame
|
32 |
* dependencies in the supported formats, the hardware has a delay between
|
33 |
* when a packet goes in, and when a picture comes out. Furthermore, this delay
|
34 |
* is not just a function of time, but also one of the dependency on additional
|
35 |
* frames being fed into the decoder to satisfy the b-frame dependencies.
|
36 |
*
|
37 |
* As such, a pipeline will build up that is roughly equivalent to the required
|
38 |
* DPB for the file being played. If that was all it took, things would still
|
39 |
* be simple - so, of course, it isn't.
|
40 |
*
|
41 |
* The hardware has a way of indicating that a picture is ready to be copied out,
|
42 |
* but this is unreliable - and sometimes the attempt will still fail so, based
|
43 |
* on testing, the code will wait until 3 pictures are ready before starting
|
44 |
* to copy out - and this has the effect of extending the pipeline.
|
45 |
*
|
46 |
* Finally, while it is tempting to say that once the decoder starts outputing
|
47 |
* frames, the software should never fail to return a frame from a decode(),
|
48 |
* this is a hard assertion to make, because the stream may switch between
|
49 |
* differently encoded content (number of b-frames, interlacing, etc) which
|
50 |
* might require a longer pipeline than before. If that happened, you could
|
51 |
* deadlock trying to retrieve a frame that can't be decoded without feeding
|
52 |
* in additional packets.
|
53 |
*
|
54 |
* As such, the code will return in the event that a picture cannot be copied
|
55 |
* out, leading to an increase in the length of the pipeline. This in turn,
|
56 |
* means we have to be sensitive to the time it takes to decode a picture;
|
57 |
* We do not want to give up just because the hardware needed a little more
|
58 |
* time to prepare the picture! For this reason, there are delays included
|
59 |
* in the decode() path that ensure that, under normal conditions, the hardware
|
60 |
* will only fail to return a frame if it really needs additional packets to
|
61 |
* complete the decoding.
|
62 |
*
|
63 |
* Finally, to be explicit, we do not want the pipeline to grow without bound
|
64 |
* for two reasons: 1) The hardware can only buffer a finite number of packets,
|
65 |
* and 2) The client application may not be able to cope with arbitrarily long
|
66 |
* delays in the video path relative to the audio path. For example. MPlayer
|
67 |
* can only handle a 20 picture delay (although this is arbitrary, and needs
|
68 |
* to be extended to fully support the CrystalHD where the delay could be up
|
69 |
* to 32 pictures - consider PAFF H.264 content with 16 b-frames).
|
70 |
*/
|
71 |
|
72 |
/*****************************************************************************
|
73 |
* Includes
|
74 |
****************************************************************************/
|
75 |
|
76 |
#define _XOPEN_SOURCE 600 |
77 |
#include <inttypes.h> |
78 |
#include <stdio.h> |
79 |
#include <stdlib.h> |
80 |
#include <unistd.h> |
81 |
|
82 |
#include <libcrystalhd/bc_dts_types.h> |
83 |
#include <libcrystalhd/bc_dts_defs.h> |
84 |
#include <libcrystalhd/libcrystalhd_if.h> |
85 |
|
86 |
#include "avcodec.h" |
87 |
#include "h264.h" |
88 |
#include "libavutil/imgutils.h" |
89 |
#include "libavutil/intreadwrite.h" |
90 |
|
91 |
/** Timeout parameter passed to DtsProcOutput() in us */
|
92 |
#define OUTPUT_PROC_TIMEOUT 50 |
93 |
/** Step between fake timestamps passed to hardware in units of 100ns */
|
94 |
#define TIMESTAMP_UNIT 100000 |
95 |
/** Initial value in us of the wait in decode() */
|
96 |
#define BASE_WAIT 10000 |
97 |
/** Increment in us to adjust wait in decode() */
|
98 |
#define WAIT_UNIT 1000 |
99 |
|
100 |
|
101 |
/*****************************************************************************
|
102 |
* Module private data
|
103 |
****************************************************************************/
|
104 |
|
105 |
typedef enum { |
106 |
RET_ERROR = -1,
|
107 |
RET_OK = 0,
|
108 |
RET_COPY_AGAIN = 1,
|
109 |
RET_SKIP_NEXT_COPY = 2,
|
110 |
RET_COPY_NEXT_FIELD = 3,
|
111 |
} CopyRet; |
112 |
|
113 |
typedef struct OpaqueList { |
114 |
struct OpaqueList *next;
|
115 |
uint64_t fake_timestamp; |
116 |
uint64_t reordered_opaque; |
117 |
uint8_t pic_type; |
118 |
} OpaqueList; |
119 |
|
120 |
typedef struct { |
121 |
AVCodecContext *avctx; |
122 |
AVFrame pic; |
123 |
HANDLE dev; |
124 |
|
125 |
AVCodecParserContext *parser; |
126 |
|
127 |
uint8_t is_70012; |
128 |
uint8_t *sps_pps_buf; |
129 |
uint32_t sps_pps_size; |
130 |
uint8_t is_nal; |
131 |
uint8_t output_ready; |
132 |
uint8_t need_second_field; |
133 |
uint8_t skip_next_output; |
134 |
uint64_t decode_wait; |
135 |
|
136 |
uint64_t last_picture; |
137 |
|
138 |
OpaqueList *head; |
139 |
OpaqueList *tail; |
140 |
} CHDContext; |
141 |
|
142 |
|
143 |
/*****************************************************************************
|
144 |
* Helper functions
|
145 |
****************************************************************************/
|
146 |
|
147 |
static inline BC_MEDIA_SUBTYPE id2subtype(CHDContext *priv, enum CodecID id) |
148 |
{ |
149 |
switch (id) {
|
150 |
case CODEC_ID_MPEG4:
|
151 |
return BC_MSUBTYPE_DIVX;
|
152 |
case CODEC_ID_MSMPEG4V3:
|
153 |
return BC_MSUBTYPE_DIVX311;
|
154 |
case CODEC_ID_MPEG2VIDEO:
|
155 |
return BC_MSUBTYPE_MPEG2VIDEO;
|
156 |
case CODEC_ID_VC1:
|
157 |
return BC_MSUBTYPE_VC1;
|
158 |
case CODEC_ID_WMV3:
|
159 |
return BC_MSUBTYPE_WMV3;
|
160 |
case CODEC_ID_H264:
|
161 |
return priv->is_nal ? BC_MSUBTYPE_AVC1 : BC_MSUBTYPE_H264;
|
162 |
default:
|
163 |
return BC_MSUBTYPE_INVALID;
|
164 |
} |
165 |
} |
166 |
|
167 |
static inline void print_frame_info(CHDContext *priv, BC_DTS_PROC_OUT *output) |
168 |
{ |
169 |
av_log(priv->avctx, AV_LOG_VERBOSE, "\tYBuffSz: %u\n", output->YbuffSz);
|
170 |
av_log(priv->avctx, AV_LOG_VERBOSE, "\tYBuffDoneSz: %u\n",
|
171 |
output->YBuffDoneSz); |
172 |
av_log(priv->avctx, AV_LOG_VERBOSE, "\tUVBuffDoneSz: %u\n",
|
173 |
output->UVBuffDoneSz); |
174 |
av_log(priv->avctx, AV_LOG_VERBOSE, "\tTimestamp: %"PRIu64"\n", |
175 |
output->PicInfo.timeStamp); |
176 |
av_log(priv->avctx, AV_LOG_VERBOSE, "\tPicture Number: %u\n",
|
177 |
output->PicInfo.picture_number); |
178 |
av_log(priv->avctx, AV_LOG_VERBOSE, "\tWidth: %u\n",
|
179 |
output->PicInfo.width); |
180 |
av_log(priv->avctx, AV_LOG_VERBOSE, "\tHeight: %u\n",
|
181 |
output->PicInfo.height); |
182 |
av_log(priv->avctx, AV_LOG_VERBOSE, "\tChroma: 0x%03x\n",
|
183 |
output->PicInfo.chroma_format); |
184 |
av_log(priv->avctx, AV_LOG_VERBOSE, "\tPulldown: %u\n",
|
185 |
output->PicInfo.pulldown); |
186 |
av_log(priv->avctx, AV_LOG_VERBOSE, "\tFlags: 0x%08x\n",
|
187 |
output->PicInfo.flags); |
188 |
av_log(priv->avctx, AV_LOG_VERBOSE, "\tFrame Rate/Res: %u\n",
|
189 |
output->PicInfo.frame_rate); |
190 |
av_log(priv->avctx, AV_LOG_VERBOSE, "\tAspect Ratio: %u\n",
|
191 |
output->PicInfo.aspect_ratio); |
192 |
av_log(priv->avctx, AV_LOG_VERBOSE, "\tColor Primaries: %u\n",
|
193 |
output->PicInfo.colour_primaries); |
194 |
av_log(priv->avctx, AV_LOG_VERBOSE, "\tMetaData: %u\n",
|
195 |
output->PicInfo.picture_meta_payload); |
196 |
av_log(priv->avctx, AV_LOG_VERBOSE, "\tSession Number: %u\n",
|
197 |
output->PicInfo.sess_num); |
198 |
av_log(priv->avctx, AV_LOG_VERBOSE, "\tycom: %u\n",
|
199 |
output->PicInfo.ycom); |
200 |
av_log(priv->avctx, AV_LOG_VERBOSE, "\tCustom Aspect: %u\n",
|
201 |
output->PicInfo.custom_aspect_ratio_width_height); |
202 |
av_log(priv->avctx, AV_LOG_VERBOSE, "\tFrames to Drop: %u\n",
|
203 |
output->PicInfo.n_drop); |
204 |
av_log(priv->avctx, AV_LOG_VERBOSE, "\tH264 Valid Fields: 0x%08x\n",
|
205 |
output->PicInfo.other.h264.valid); |
206 |
} |
207 |
|
208 |
|
209 |
/*****************************************************************************
|
210 |
* OpaqueList functions
|
211 |
****************************************************************************/
|
212 |
|
213 |
static uint64_t opaque_list_push(CHDContext *priv, uint64_t reordered_opaque,
|
214 |
uint8_t pic_type) |
215 |
{ |
216 |
OpaqueList *newNode = av_mallocz(sizeof (OpaqueList));
|
217 |
if (!newNode) {
|
218 |
av_log(priv->avctx, AV_LOG_ERROR, |
219 |
"Unable to allocate new node in OpaqueList.\n");
|
220 |
return 0; |
221 |
} |
222 |
if (!priv->head) {
|
223 |
newNode->fake_timestamp = TIMESTAMP_UNIT; |
224 |
priv->head = newNode; |
225 |
} else {
|
226 |
newNode->fake_timestamp = priv->tail->fake_timestamp + TIMESTAMP_UNIT; |
227 |
priv->tail->next = newNode; |
228 |
} |
229 |
priv->tail = newNode; |
230 |
newNode->reordered_opaque = reordered_opaque; |
231 |
newNode->pic_type = pic_type; |
232 |
|
233 |
return newNode->fake_timestamp;
|
234 |
} |
235 |
|
236 |
/*
|
237 |
* The OpaqueList is built in decode order, while elements will be removed
|
238 |
* in presentation order. If frames are reordered, this means we must be
|
239 |
* able to remove elements that are not the first element.
|
240 |
*
|
241 |
* Returned node must be freed by caller.
|
242 |
*/
|
243 |
static OpaqueList *opaque_list_pop(CHDContext *priv, uint64_t fake_timestamp)
|
244 |
{ |
245 |
OpaqueList *node = priv->head; |
246 |
|
247 |
if (!priv->head) {
|
248 |
av_log(priv->avctx, AV_LOG_ERROR, |
249 |
"CrystalHD: Attempted to query non-existent timestamps.\n");
|
250 |
return NULL; |
251 |
} |
252 |
|
253 |
/*
|
254 |
* The first element is special-cased because we have to manipulate
|
255 |
* the head pointer rather than the previous element in the list.
|
256 |
*/
|
257 |
if (priv->head->fake_timestamp == fake_timestamp) {
|
258 |
priv->head = node->next; |
259 |
|
260 |
if (!priv->head->next)
|
261 |
priv->tail = priv->head; |
262 |
|
263 |
node->next = NULL;
|
264 |
return node;
|
265 |
} |
266 |
|
267 |
/*
|
268 |
* The list is processed at arm's length so that we have the
|
269 |
* previous element available to rewrite its next pointer.
|
270 |
*/
|
271 |
while (node->next) {
|
272 |
OpaqueList *current = node->next; |
273 |
if (current->fake_timestamp == fake_timestamp) {
|
274 |
node->next = current->next; |
275 |
|
276 |
if (!node->next)
|
277 |
priv->tail = node; |
278 |
|
279 |
current->next = NULL;
|
280 |
return current;
|
281 |
} else {
|
282 |
node = current; |
283 |
} |
284 |
} |
285 |
|
286 |
av_log(priv->avctx, AV_LOG_VERBOSE, |
287 |
"CrystalHD: Couldn't match fake_timestamp.\n");
|
288 |
return NULL; |
289 |
} |
290 |
|
291 |
|
292 |
/*****************************************************************************
|
293 |
* Video decoder API function definitions
|
294 |
****************************************************************************/
|
295 |
|
296 |
static void flush(AVCodecContext *avctx) |
297 |
{ |
298 |
CHDContext *priv = avctx->priv_data; |
299 |
|
300 |
avctx->has_b_frames = 0;
|
301 |
priv->last_picture = -1;
|
302 |
priv->output_ready = 0;
|
303 |
priv->need_second_field = 0;
|
304 |
priv->skip_next_output = 0;
|
305 |
priv->decode_wait = BASE_WAIT; |
306 |
|
307 |
if (priv->pic.data[0]) |
308 |
avctx->release_buffer(avctx, &priv->pic); |
309 |
|
310 |
/* Flush mode 4 flushes all software and hardware buffers. */
|
311 |
DtsFlushInput(priv->dev, 4);
|
312 |
} |
313 |
|
314 |
|
315 |
static av_cold int uninit(AVCodecContext *avctx) |
316 |
{ |
317 |
CHDContext *priv = avctx->priv_data; |
318 |
HANDLE device; |
319 |
|
320 |
device = priv->dev; |
321 |
DtsStopDecoder(device); |
322 |
DtsCloseDecoder(device); |
323 |
DtsDeviceClose(device); |
324 |
|
325 |
av_parser_close(priv->parser); |
326 |
|
327 |
av_free(priv->sps_pps_buf); |
328 |
|
329 |
if (priv->pic.data[0]) |
330 |
avctx->release_buffer(avctx, &priv->pic); |
331 |
|
332 |
if (priv->head) {
|
333 |
OpaqueList *node = priv->head; |
334 |
while (node) {
|
335 |
OpaqueList *next = node->next; |
336 |
av_free(node); |
337 |
node = next; |
338 |
} |
339 |
} |
340 |
|
341 |
return 0; |
342 |
} |
343 |
|
344 |
|
345 |
static av_cold int init(AVCodecContext *avctx) |
346 |
{ |
347 |
CHDContext* priv; |
348 |
BC_STATUS ret; |
349 |
BC_INFO_CRYSTAL version; |
350 |
BC_INPUT_FORMAT format = { |
351 |
.FGTEnable = FALSE, |
352 |
.Progressive = TRUE, |
353 |
.OptFlags = 0x80000000 | vdecFrameRate59_94 | 0x40, |
354 |
.width = avctx->width, |
355 |
.height = avctx->height, |
356 |
}; |
357 |
|
358 |
BC_MEDIA_SUBTYPE subtype; |
359 |
|
360 |
uint32_t mode = DTS_PLAYBACK_MODE | |
361 |
DTS_LOAD_FILE_PLAY_FW | |
362 |
DTS_SKIP_TX_CHK_CPB | |
363 |
DTS_PLAYBACK_DROP_RPT_MODE | |
364 |
DTS_SINGLE_THREADED_MODE | |
365 |
DTS_DFLT_RESOLUTION(vdecRESOLUTION_1080p23_976); |
366 |
|
367 |
av_log(avctx, AV_LOG_VERBOSE, "CrystalHD Init for %s\n",
|
368 |
avctx->codec->name); |
369 |
|
370 |
avctx->pix_fmt = PIX_FMT_YUYV422; |
371 |
|
372 |
/* Initialize the library */
|
373 |
priv = avctx->priv_data; |
374 |
priv->avctx = avctx; |
375 |
priv->is_nal = avctx->extradata_size > 0 && *(avctx->extradata) == 1; |
376 |
priv->last_picture = -1;
|
377 |
priv->decode_wait = BASE_WAIT; |
378 |
|
379 |
subtype = id2subtype(priv, avctx->codec->id); |
380 |
switch (subtype) {
|
381 |
case BC_MSUBTYPE_AVC1:
|
382 |
{ |
383 |
uint8_t *dummy_p; |
384 |
int dummy_int;
|
385 |
AVBitStreamFilterContext *bsfc; |
386 |
|
387 |
uint32_t orig_data_size = avctx->extradata_size; |
388 |
uint8_t *orig_data = av_malloc(orig_data_size); |
389 |
if (!orig_data) {
|
390 |
av_log(avctx, AV_LOG_ERROR, |
391 |
"Failed to allocate copy of extradata\n");
|
392 |
return AVERROR(ENOMEM);
|
393 |
} |
394 |
memcpy(orig_data, avctx->extradata, orig_data_size); |
395 |
|
396 |
|
397 |
bsfc = av_bitstream_filter_init("h264_mp4toannexb");
|
398 |
if (!bsfc) {
|
399 |
av_log(avctx, AV_LOG_ERROR, |
400 |
"Cannot open the h264_mp4toannexb BSF!\n");
|
401 |
av_free(orig_data); |
402 |
return AVERROR_BSF_NOT_FOUND;
|
403 |
} |
404 |
av_bitstream_filter_filter(bsfc, avctx, NULL, &dummy_p,
|
405 |
&dummy_int, NULL, 0, 0); |
406 |
av_bitstream_filter_close(bsfc); |
407 |
|
408 |
priv->sps_pps_buf = avctx->extradata; |
409 |
priv->sps_pps_size = avctx->extradata_size; |
410 |
avctx->extradata = orig_data; |
411 |
avctx->extradata_size = orig_data_size; |
412 |
|
413 |
format.pMetaData = priv->sps_pps_buf; |
414 |
format.metaDataSz = priv->sps_pps_size; |
415 |
format.startCodeSz = (avctx->extradata[4] & 0x03) + 1; |
416 |
} |
417 |
break;
|
418 |
case BC_MSUBTYPE_H264:
|
419 |
format.startCodeSz = 4;
|
420 |
// Fall-through
|
421 |
case BC_MSUBTYPE_VC1:
|
422 |
case BC_MSUBTYPE_WVC1:
|
423 |
case BC_MSUBTYPE_WMV3:
|
424 |
case BC_MSUBTYPE_WMVA:
|
425 |
case BC_MSUBTYPE_MPEG2VIDEO:
|
426 |
case BC_MSUBTYPE_DIVX:
|
427 |
case BC_MSUBTYPE_DIVX311:
|
428 |
format.pMetaData = avctx->extradata; |
429 |
format.metaDataSz = avctx->extradata_size; |
430 |
break;
|
431 |
default:
|
432 |
av_log(avctx, AV_LOG_ERROR, "CrystalHD: Unknown codec name\n");
|
433 |
return AVERROR(EINVAL);
|
434 |
} |
435 |
format.mSubtype = subtype; |
436 |
|
437 |
/* Get a decoder instance */
|
438 |
av_log(avctx, AV_LOG_VERBOSE, "CrystalHD: starting up\n");
|
439 |
// Initialize the Link and Decoder devices
|
440 |
ret = DtsDeviceOpen(&priv->dev, mode); |
441 |
if (ret != BC_STS_SUCCESS) {
|
442 |
av_log(avctx, AV_LOG_VERBOSE, "CrystalHD: DtsDeviceOpen failed\n");
|
443 |
goto fail;
|
444 |
} |
445 |
|
446 |
ret = DtsCrystalHDVersion(priv->dev, &version); |
447 |
if (ret != BC_STS_SUCCESS) {
|
448 |
av_log(avctx, AV_LOG_VERBOSE, |
449 |
"CrystalHD: DtsCrystalHDVersion failed\n");
|
450 |
goto fail;
|
451 |
} |
452 |
priv->is_70012 = version.device == 0;
|
453 |
|
454 |
if (priv->is_70012 &&
|
455 |
(subtype == BC_MSUBTYPE_DIVX || subtype == BC_MSUBTYPE_DIVX311)) { |
456 |
av_log(avctx, AV_LOG_VERBOSE, |
457 |
"CrystalHD: BCM70012 doesn't support MPEG4-ASP/DivX/Xvid\n");
|
458 |
goto fail;
|
459 |
} |
460 |
|
461 |
ret = DtsSetInputFormat(priv->dev, &format); |
462 |
if (ret != BC_STS_SUCCESS) {
|
463 |
av_log(avctx, AV_LOG_ERROR, "CrystalHD: SetInputFormat failed\n");
|
464 |
goto fail;
|
465 |
} |
466 |
|
467 |
ret = DtsOpenDecoder(priv->dev, BC_STREAM_TYPE_ES); |
468 |
if (ret != BC_STS_SUCCESS) {
|
469 |
av_log(avctx, AV_LOG_ERROR, "CrystalHD: DtsOpenDecoder failed\n");
|
470 |
goto fail;
|
471 |
} |
472 |
|
473 |
ret = DtsSetColorSpace(priv->dev, OUTPUT_MODE422_YUY2); |
474 |
if (ret != BC_STS_SUCCESS) {
|
475 |
av_log(avctx, AV_LOG_ERROR, "CrystalHD: DtsSetColorSpace failed\n");
|
476 |
goto fail;
|
477 |
} |
478 |
ret = DtsStartDecoder(priv->dev); |
479 |
if (ret != BC_STS_SUCCESS) {
|
480 |
av_log(avctx, AV_LOG_ERROR, "CrystalHD: DtsStartDecoder failed\n");
|
481 |
goto fail;
|
482 |
} |
483 |
ret = DtsStartCapture(priv->dev); |
484 |
if (ret != BC_STS_SUCCESS) {
|
485 |
av_log(avctx, AV_LOG_ERROR, "CrystalHD: DtsStartCapture failed\n");
|
486 |
goto fail;
|
487 |
} |
488 |
|
489 |
if (avctx->codec->id == CODEC_ID_H264) {
|
490 |
priv->parser = av_parser_init(avctx->codec->id); |
491 |
if (!priv->parser)
|
492 |
av_log(avctx, AV_LOG_WARNING, |
493 |
"Cannot open the h.264 parser! Interlaced h.264 content "
|
494 |
"will not be detected reliably.\n");
|
495 |
} |
496 |
av_log(avctx, AV_LOG_VERBOSE, "CrystalHD: Init complete.\n");
|
497 |
|
498 |
return 0; |
499 |
|
500 |
fail:
|
501 |
uninit(avctx); |
502 |
return -1; |
503 |
} |
504 |
|
505 |
|
506 |
/*
|
507 |
* The CrystalHD doesn't report interlaced H.264 content in a way that allows
|
508 |
* us to distinguish between specific cases that require different handling.
|
509 |
* So, for now, we have to hard-code the behaviour we want.
|
510 |
*
|
511 |
* The default behaviour is to assume MBAFF with input and output fieldpairs.
|
512 |
*
|
513 |
* Define ASSUME_PAFF_OVER_MBAFF to treat input as PAFF with separate input
|
514 |
* and output fields.
|
515 |
*
|
516 |
* Define ASSUME_TWO_INPUTS_ONE_OUTPUT to treat input as separate fields but
|
517 |
* output as a single fieldpair.
|
518 |
*
|
519 |
* Define both to mess up your playback.
|
520 |
*/
|
521 |
#define ASSUME_PAFF_OVER_MBAFF 0 |
522 |
#define ASSUME_TWO_INPUTS_ONE_OUTPUT 0 |
523 |
static inline CopyRet copy_frame(AVCodecContext *avctx, |
524 |
BC_DTS_PROC_OUT *output, |
525 |
void *data, int *data_size, |
526 |
uint8_t second_field) |
527 |
{ |
528 |
BC_STATUS ret; |
529 |
BC_DTS_STATUS decoder_status; |
530 |
uint8_t is_paff; |
531 |
uint8_t next_frame_same; |
532 |
uint8_t interlaced; |
533 |
|
534 |
CHDContext *priv = avctx->priv_data; |
535 |
int64_t pkt_pts = AV_NOPTS_VALUE; |
536 |
uint8_t pic_type = 0;
|
537 |
|
538 |
uint8_t bottom_field = (output->PicInfo.flags & VDEC_FLAG_BOTTOMFIELD) == |
539 |
VDEC_FLAG_BOTTOMFIELD; |
540 |
uint8_t bottom_first = !!(output->PicInfo.flags & VDEC_FLAG_BOTTOM_FIRST); |
541 |
|
542 |
int width = output->PicInfo.width;
|
543 |
int height = output->PicInfo.height;
|
544 |
int bwidth;
|
545 |
uint8_t *src = output->Ybuff; |
546 |
int sStride;
|
547 |
uint8_t *dst; |
548 |
int dStride;
|
549 |
|
550 |
if (output->PicInfo.timeStamp != 0) { |
551 |
OpaqueList *node = opaque_list_pop(priv, output->PicInfo.timeStamp); |
552 |
if (node) {
|
553 |
pkt_pts = node->reordered_opaque; |
554 |
pic_type = node->pic_type; |
555 |
av_free(node); |
556 |
} else {
|
557 |
/*
|
558 |
* We will encounter a situation where a timestamp cannot be
|
559 |
* popped if a second field is being returned. In this case,
|
560 |
* each field has the same timestamp and the first one will
|
561 |
* cause it to be popped. To keep subsequent calculations
|
562 |
* simple, pic_type should be set a FIELD value - doesn't
|
563 |
* matter which, but I chose BOTTOM.
|
564 |
*/
|
565 |
pic_type = PICT_BOTTOM_FIELD; |
566 |
} |
567 |
av_log(avctx, AV_LOG_VERBOSE, "output \"pts\": %"PRIu64"\n", |
568 |
output->PicInfo.timeStamp); |
569 |
av_log(avctx, AV_LOG_VERBOSE, "output picture type %d\n",
|
570 |
pic_type); |
571 |
} |
572 |
|
573 |
ret = DtsGetDriverStatus(priv->dev, &decoder_status); |
574 |
if (ret != BC_STS_SUCCESS) {
|
575 |
av_log(avctx, AV_LOG_ERROR, |
576 |
"CrystalHD: GetDriverStatus failed: %u\n", ret);
|
577 |
return RET_ERROR;
|
578 |
} |
579 |
|
580 |
is_paff = ASSUME_PAFF_OVER_MBAFF || |
581 |
!(output->PicInfo.flags & VDEC_FLAG_UNKNOWN_SRC); |
582 |
next_frame_same = output->PicInfo.picture_number == |
583 |
(decoder_status.picNumFlags & ~0x40000000);
|
584 |
interlaced = ((output->PicInfo.flags & |
585 |
VDEC_FLAG_INTERLACED_SRC) && is_paff) || |
586 |
next_frame_same || bottom_field || second_field; |
587 |
|
588 |
av_log(avctx, AV_LOG_VERBOSE, "CrystalHD: next_frame_same: %u | %u | %u\n",
|
589 |
next_frame_same, output->PicInfo.picture_number, |
590 |
decoder_status.picNumFlags & ~0x40000000);
|
591 |
|
592 |
if (priv->pic.data[0] && !priv->need_second_field) |
593 |
avctx->release_buffer(avctx, &priv->pic); |
594 |
|
595 |
priv->need_second_field = interlaced && !priv->need_second_field; |
596 |
|
597 |
priv->pic.buffer_hints = FF_BUFFER_HINTS_VALID | FF_BUFFER_HINTS_PRESERVE | |
598 |
FF_BUFFER_HINTS_REUSABLE; |
599 |
if (!priv->pic.data[0]) { |
600 |
if (avctx->get_buffer(avctx, &priv->pic) < 0) { |
601 |
av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
|
602 |
return RET_ERROR;
|
603 |
} |
604 |
} |
605 |
|
606 |
bwidth = av_image_get_linesize(avctx->pix_fmt, width, 0);
|
607 |
if (priv->is_70012) {
|
608 |
int pStride;
|
609 |
|
610 |
if (width <= 720) |
611 |
pStride = 720;
|
612 |
else if (width <= 1280) |
613 |
pStride = 1280;
|
614 |
else if (width <= 1080) |
615 |
pStride = 1080;
|
616 |
sStride = av_image_get_linesize(avctx->pix_fmt, pStride, 0);
|
617 |
} else {
|
618 |
sStride = bwidth; |
619 |
} |
620 |
|
621 |
dStride = priv->pic.linesize[0];
|
622 |
dst = priv->pic.data[0];
|
623 |
|
624 |
av_log(priv->avctx, AV_LOG_VERBOSE, "CrystalHD: Copying out frame\n");
|
625 |
|
626 |
if (interlaced) {
|
627 |
int dY = 0; |
628 |
int sY = 0; |
629 |
|
630 |
height /= 2;
|
631 |
if (bottom_field) {
|
632 |
av_log(priv->avctx, AV_LOG_VERBOSE, "Interlaced: bottom field\n");
|
633 |
dY = 1;
|
634 |
} else {
|
635 |
av_log(priv->avctx, AV_LOG_VERBOSE, "Interlaced: top field\n");
|
636 |
dY = 0;
|
637 |
} |
638 |
|
639 |
for (sY = 0; sY < height; dY++, sY++) { |
640 |
memcpy(&(dst[dY * dStride]), &(src[sY * sStride]), bwidth); |
641 |
dY++; |
642 |
} |
643 |
} else {
|
644 |
av_image_copy_plane(dst, dStride, src, sStride, bwidth, height); |
645 |
} |
646 |
|
647 |
priv->pic.interlaced_frame = interlaced; |
648 |
if (interlaced)
|
649 |
priv->pic.top_field_first = !bottom_first; |
650 |
|
651 |
priv->pic.pkt_pts = pkt_pts; |
652 |
|
653 |
if (!priv->need_second_field) {
|
654 |
*data_size = sizeof(AVFrame);
|
655 |
*(AVFrame *)data = priv->pic; |
656 |
} |
657 |
|
658 |
if (ASSUME_TWO_INPUTS_ONE_OUTPUT &&
|
659 |
output->PicInfo.flags & VDEC_FLAG_UNKNOWN_SRC) { |
660 |
av_log(priv->avctx, AV_LOG_VERBOSE, "Fieldpair from two packets.\n");
|
661 |
return RET_SKIP_NEXT_COPY;
|
662 |
} |
663 |
|
664 |
/*
|
665 |
* Testing has shown that in all cases where we don't want to return the
|
666 |
* full frame immediately, VDEC_FLAG_UNKNOWN_SRC is set.
|
667 |
*/
|
668 |
return priv->need_second_field &&
|
669 |
!(output->PicInfo.flags & VDEC_FLAG_UNKNOWN_SRC) ? |
670 |
RET_COPY_NEXT_FIELD : RET_OK; |
671 |
} |
672 |
|
673 |
|
674 |
static inline CopyRet receive_frame(AVCodecContext *avctx, |
675 |
void *data, int *data_size, |
676 |
uint8_t second_field) |
677 |
{ |
678 |
BC_STATUS ret; |
679 |
BC_DTS_PROC_OUT output = { |
680 |
.PicInfo.width = avctx->width, |
681 |
.PicInfo.height = avctx->height, |
682 |
}; |
683 |
CHDContext *priv = avctx->priv_data; |
684 |
HANDLE dev = priv->dev; |
685 |
|
686 |
*data_size = 0;
|
687 |
|
688 |
// Request decoded data from the driver
|
689 |
ret = DtsProcOutputNoCopy(dev, OUTPUT_PROC_TIMEOUT, &output); |
690 |
if (ret == BC_STS_FMT_CHANGE) {
|
691 |
av_log(avctx, AV_LOG_VERBOSE, "CrystalHD: Initial format change\n");
|
692 |
avctx->width = output.PicInfo.width; |
693 |
avctx->height = output.PicInfo.height; |
694 |
return RET_COPY_AGAIN;
|
695 |
} else if (ret == BC_STS_SUCCESS) { |
696 |
int copy_ret = -1; |
697 |
if (output.PoutFlags & BC_POUT_FLAGS_PIB_VALID) {
|
698 |
if (priv->last_picture == -1) { |
699 |
/*
|
700 |
* Init to one less, so that the incrementing code doesn't
|
701 |
* need to be special-cased.
|
702 |
*/
|
703 |
priv->last_picture = output.PicInfo.picture_number - 1;
|
704 |
} |
705 |
|
706 |
if (avctx->codec->id == CODEC_ID_MPEG4 &&
|
707 |
output.PicInfo.timeStamp == 0) {
|
708 |
av_log(avctx, AV_LOG_VERBOSE, |
709 |
"CrystalHD: Not returning packed frame twice.\n");
|
710 |
priv->last_picture++; |
711 |
DtsReleaseOutputBuffs(dev, NULL, FALSE);
|
712 |
return RET_COPY_AGAIN;
|
713 |
} |
714 |
|
715 |
print_frame_info(priv, &output); |
716 |
|
717 |
if (priv->last_picture + 1 < output.PicInfo.picture_number) { |
718 |
av_log(avctx, AV_LOG_WARNING, |
719 |
"CrystalHD: Picture Number discontinuity\n");
|
720 |
/*
|
721 |
* Have we lost frames? If so, we need to shrink the
|
722 |
* pipeline length appropriately.
|
723 |
*
|
724 |
* XXX: I have no idea what the semantics of this situation
|
725 |
* are so I don't even know if we've lost frames or which
|
726 |
* ones.
|
727 |
*
|
728 |
* In any case, only warn the first time.
|
729 |
*/
|
730 |
priv->last_picture = output.PicInfo.picture_number - 1;
|
731 |
} |
732 |
|
733 |
copy_ret = copy_frame(avctx, &output, data, data_size, second_field); |
734 |
if (*data_size > 0) { |
735 |
avctx->has_b_frames--; |
736 |
priv->last_picture++; |
737 |
av_log(avctx, AV_LOG_VERBOSE, "CrystalHD: Pipeline length: %u\n",
|
738 |
avctx->has_b_frames); |
739 |
} |
740 |
} else {
|
741 |
/*
|
742 |
* An invalid frame has been consumed.
|
743 |
*/
|
744 |
av_log(avctx, AV_LOG_ERROR, "CrystalHD: ProcOutput succeeded with "
|
745 |
"invalid PIB\n");
|
746 |
avctx->has_b_frames--; |
747 |
copy_ret = RET_OK; |
748 |
} |
749 |
DtsReleaseOutputBuffs(dev, NULL, FALSE);
|
750 |
|
751 |
return copy_ret;
|
752 |
} else if (ret == BC_STS_BUSY) { |
753 |
return RET_COPY_AGAIN;
|
754 |
} else {
|
755 |
av_log(avctx, AV_LOG_ERROR, "CrystalHD: ProcOutput failed %d\n", ret);
|
756 |
return RET_ERROR;
|
757 |
} |
758 |
} |
759 |
|
760 |
|
761 |
static int decode(AVCodecContext *avctx, void *data, int *data_size, AVPacket *avpkt) |
762 |
{ |
763 |
BC_STATUS ret; |
764 |
BC_DTS_STATUS decoder_status; |
765 |
CopyRet rec_ret; |
766 |
CHDContext *priv = avctx->priv_data; |
767 |
HANDLE dev = priv->dev; |
768 |
int len = avpkt->size;
|
769 |
uint8_t pic_type = 0;
|
770 |
|
771 |
av_log(avctx, AV_LOG_VERBOSE, "CrystalHD: decode_frame\n");
|
772 |
|
773 |
if (len) {
|
774 |
int32_t tx_free = (int32_t)DtsTxFreeSize(dev); |
775 |
|
776 |
if (priv->parser) {
|
777 |
uint8_t *pout; |
778 |
int psize = len;
|
779 |
H264Context *h = priv->parser->priv_data; |
780 |
|
781 |
while (psize)
|
782 |
ret = av_parser_parse2(priv->parser, avctx, &pout, &psize, |
783 |
avpkt->data, len, avctx->pkt->pts, |
784 |
avctx->pkt->dts, len - psize); |
785 |
av_log(avctx, AV_LOG_VERBOSE, |
786 |
"CrystalHD: parser picture type %d\n",
|
787 |
h->s.picture_structure); |
788 |
pic_type = h->s.picture_structure; |
789 |
} |
790 |
|
791 |
if (len < tx_free - 1024) { |
792 |
/*
|
793 |
* Despite being notionally opaque, either libcrystalhd or
|
794 |
* the hardware itself will mangle pts values that are too
|
795 |
* small or too large. The docs claim it should be in units
|
796 |
* of 100ns. Given that we're nominally dealing with a black
|
797 |
* box on both sides, any transform we do has no guarantee of
|
798 |
* avoiding mangling so we need to build a mapping to values
|
799 |
* we know will not be mangled.
|
800 |
*/
|
801 |
uint64_t pts = opaque_list_push(priv, avctx->pkt->pts, pic_type); |
802 |
if (!pts) {
|
803 |
return AVERROR(ENOMEM);
|
804 |
} |
805 |
av_log(priv->avctx, AV_LOG_VERBOSE, |
806 |
"input \"pts\": %"PRIu64"\n", pts); |
807 |
ret = DtsProcInput(dev, avpkt->data, len, pts, 0);
|
808 |
if (ret == BC_STS_BUSY) {
|
809 |
av_log(avctx, AV_LOG_WARNING, |
810 |
"CrystalHD: ProcInput returned busy\n");
|
811 |
usleep(BASE_WAIT); |
812 |
return AVERROR(EBUSY);
|
813 |
} else if (ret != BC_STS_SUCCESS) { |
814 |
av_log(avctx, AV_LOG_ERROR, |
815 |
"CrystalHD: ProcInput failed: %u\n", ret);
|
816 |
return -1; |
817 |
} |
818 |
avctx->has_b_frames++; |
819 |
} else {
|
820 |
av_log(avctx, AV_LOG_WARNING, "CrystalHD: Input buffer full\n");
|
821 |
len = 0; // We didn't consume any bytes. |
822 |
} |
823 |
} else {
|
824 |
av_log(avctx, AV_LOG_INFO, "CrystalHD: No more input data\n");
|
825 |
} |
826 |
|
827 |
if (priv->skip_next_output) {
|
828 |
av_log(avctx, AV_LOG_VERBOSE, "CrystalHD: Skipping next output.\n");
|
829 |
priv->skip_next_output = 0;
|
830 |
avctx->has_b_frames--; |
831 |
return len;
|
832 |
} |
833 |
|
834 |
ret = DtsGetDriverStatus(dev, &decoder_status); |
835 |
if (ret != BC_STS_SUCCESS) {
|
836 |
av_log(avctx, AV_LOG_ERROR, "CrystalHD: GetDriverStatus failed\n");
|
837 |
return -1; |
838 |
} |
839 |
|
840 |
/*
|
841 |
* No frames ready. Don't try to extract.
|
842 |
*
|
843 |
* Empirical testing shows that ReadyListCount can be a damn lie,
|
844 |
* and ProcOut still fails when count > 0. The same testing showed
|
845 |
* that two more iterations were needed before ProcOutput would
|
846 |
* succeed.
|
847 |
*/
|
848 |
if (priv->output_ready < 2) { |
849 |
if (decoder_status.ReadyListCount != 0) |
850 |
priv->output_ready++; |
851 |
usleep(BASE_WAIT); |
852 |
av_log(avctx, AV_LOG_INFO, "CrystalHD: Filling pipeline.\n");
|
853 |
return len;
|
854 |
} else if (decoder_status.ReadyListCount == 0) { |
855 |
/*
|
856 |
* After the pipeline is established, if we encounter a lack of frames
|
857 |
* that probably means we're not giving the hardware enough time to
|
858 |
* decode them, so start increasing the wait time at the end of a
|
859 |
* decode call.
|
860 |
*/
|
861 |
usleep(BASE_WAIT); |
862 |
priv->decode_wait += WAIT_UNIT; |
863 |
av_log(avctx, AV_LOG_INFO, "CrystalHD: No frames ready. Returning\n");
|
864 |
return len;
|
865 |
} |
866 |
|
867 |
do {
|
868 |
rec_ret = receive_frame(avctx, data, data_size, 0);
|
869 |
if (rec_ret == RET_OK && *data_size == 0) { |
870 |
/*
|
871 |
* This case is for when the encoded fields are stored
|
872 |
* separately and we get a separate avpkt for each one. To keep
|
873 |
* the pipeline stable, we should return nothing and wait for
|
874 |
* the next time round to grab the second field.
|
875 |
* H.264 PAFF is an example of this.
|
876 |
*/
|
877 |
av_log(avctx, AV_LOG_VERBOSE, "Returning after first field.\n");
|
878 |
avctx->has_b_frames--; |
879 |
} else if (rec_ret == RET_COPY_NEXT_FIELD) { |
880 |
/*
|
881 |
* This case is for when the encoded fields are stored in a
|
882 |
* single avpkt but the hardware returns then separately. Unless
|
883 |
* we grab the second field before returning, we'll slip another
|
884 |
* frame in the pipeline and if that happens a lot, we're sunk.
|
885 |
* So we have to get that second field now.
|
886 |
* Interlaced mpeg2 and vc1 are examples of this.
|
887 |
*/
|
888 |
av_log(avctx, AV_LOG_VERBOSE, "Trying to get second field.\n");
|
889 |
while (1) { |
890 |
usleep(priv->decode_wait); |
891 |
ret = DtsGetDriverStatus(dev, &decoder_status); |
892 |
if (ret == BC_STS_SUCCESS &&
|
893 |
decoder_status.ReadyListCount > 0) {
|
894 |
rec_ret = receive_frame(avctx, data, data_size, 1);
|
895 |
if ((rec_ret == RET_OK && *data_size > 0) || |
896 |
rec_ret == RET_ERROR) |
897 |
break;
|
898 |
} |
899 |
} |
900 |
av_log(avctx, AV_LOG_VERBOSE, "CrystalHD: Got second field.\n");
|
901 |
} else if (rec_ret == RET_SKIP_NEXT_COPY) { |
902 |
/*
|
903 |
* Two input packets got turned into a field pair. Gawd.
|
904 |
*/
|
905 |
av_log(avctx, AV_LOG_VERBOSE, |
906 |
"Don't output on next decode call.\n");
|
907 |
priv->skip_next_output = 1;
|
908 |
} |
909 |
/*
|
910 |
* If rec_ret == RET_COPY_AGAIN, that means that either we just handled
|
911 |
* a FMT_CHANGE event and need to go around again for the actual frame,
|
912 |
* we got a busy status and need to try again, or we're dealing with
|
913 |
* packed b-frames, where the hardware strangely returns the packed
|
914 |
* p-frame twice. We choose to keep the second copy as it carries the
|
915 |
* valid pts.
|
916 |
*/
|
917 |
} while (rec_ret == RET_COPY_AGAIN);
|
918 |
usleep(priv->decode_wait); |
919 |
return len;
|
920 |
} |
921 |
|
922 |
|
923 |
#if CONFIG_H264_CRYSTALHD_DECODER
|
924 |
AVCodec ff_h264_crystalhd_decoder = { |
925 |
.name = "h264_crystalhd",
|
926 |
.type = AVMEDIA_TYPE_VIDEO, |
927 |
.id = CODEC_ID_H264, |
928 |
.priv_data_size = sizeof(CHDContext),
|
929 |
.init = init, |
930 |
.close = uninit, |
931 |
.decode = decode, |
932 |
.capabilities = CODEC_CAP_DR1 | CODEC_CAP_DELAY | CODEC_CAP_EXPERIMENTAL, |
933 |
.flush = flush, |
934 |
.long_name = NULL_IF_CONFIG_SMALL("H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10 (CrystalHD acceleration)"),
|
935 |
.pix_fmts = (const enum PixelFormat[]){PIX_FMT_YUYV422, PIX_FMT_NONE}, |
936 |
}; |
937 |
#endif
|
938 |
|
939 |
#if CONFIG_MPEG2_CRYSTALHD_DECODER
|
940 |
AVCodec ff_mpeg2_crystalhd_decoder = { |
941 |
.name = "mpeg2_crystalhd",
|
942 |
.type = AVMEDIA_TYPE_VIDEO, |
943 |
.id = CODEC_ID_MPEG2VIDEO, |
944 |
.priv_data_size = sizeof(CHDContext),
|
945 |
.init = init, |
946 |
.close = uninit, |
947 |
.decode = decode, |
948 |
.capabilities = CODEC_CAP_DR1 | CODEC_CAP_DELAY | CODEC_CAP_EXPERIMENTAL, |
949 |
.flush = flush, |
950 |
.long_name = NULL_IF_CONFIG_SMALL("MPEG-2 Video (CrystalHD acceleration)"),
|
951 |
.pix_fmts = (const enum PixelFormat[]){PIX_FMT_YUYV422, PIX_FMT_NONE}, |
952 |
}; |
953 |
#endif
|
954 |
|
955 |
#if CONFIG_MPEG4_CRYSTALHD_DECODER
|
956 |
AVCodec ff_mpeg4_crystalhd_decoder = { |
957 |
.name = "mpeg4_crystalhd",
|
958 |
.type = AVMEDIA_TYPE_VIDEO, |
959 |
.id = CODEC_ID_MPEG4, |
960 |
.priv_data_size = sizeof(CHDContext),
|
961 |
.init = init, |
962 |
.close = uninit, |
963 |
.decode = decode, |
964 |
.capabilities = CODEC_CAP_DR1 | CODEC_CAP_DELAY | CODEC_CAP_EXPERIMENTAL, |
965 |
.flush = flush, |
966 |
.long_name = NULL_IF_CONFIG_SMALL("MPEG-4 Part 2 (CrystalHD acceleration)"),
|
967 |
.pix_fmts = (const enum PixelFormat[]){PIX_FMT_YUYV422, PIX_FMT_NONE}, |
968 |
}; |
969 |
#endif
|
970 |
|
971 |
#if CONFIG_MSMPEG4_CRYSTALHD_DECODER
|
972 |
AVCodec ff_msmpeg4_crystalhd_decoder = { |
973 |
.name = "msmpeg4_crystalhd",
|
974 |
.type = AVMEDIA_TYPE_VIDEO, |
975 |
.id = CODEC_ID_MSMPEG4V3, |
976 |
.priv_data_size = sizeof(CHDContext),
|
977 |
.init = init, |
978 |
.close = uninit, |
979 |
.decode = decode, |
980 |
.capabilities = CODEC_CAP_DR1 | CODEC_CAP_DELAY | CODEC_CAP_EXPERIMENTAL, |
981 |
.flush = flush, |
982 |
.long_name = NULL_IF_CONFIG_SMALL("MPEG-4 Part 2 Microsoft variant version 3 (CrystalHD acceleration)"),
|
983 |
.pix_fmts = (const enum PixelFormat[]){PIX_FMT_YUYV422, PIX_FMT_NONE}, |
984 |
}; |
985 |
#endif
|
986 |
|
987 |
#if CONFIG_VC1_CRYSTALHD_DECODER
|
988 |
AVCodec ff_vc1_crystalhd_decoder = { |
989 |
.name = "vc1_crystalhd",
|
990 |
.type = AVMEDIA_TYPE_VIDEO, |
991 |
.id = CODEC_ID_VC1, |
992 |
.priv_data_size = sizeof(CHDContext),
|
993 |
.init = init, |
994 |
.close = uninit, |
995 |
.decode = decode, |
996 |
.capabilities = CODEC_CAP_DR1 | CODEC_CAP_DELAY | CODEC_CAP_EXPERIMENTAL, |
997 |
.flush = flush, |
998 |
.long_name = NULL_IF_CONFIG_SMALL("SMPTE VC-1 (CrystalHD acceleration)"),
|
999 |
.pix_fmts = (const enum PixelFormat[]){PIX_FMT_YUYV422, PIX_FMT_NONE}, |
1000 |
}; |
1001 |
#endif
|
1002 |
|
1003 |
#if CONFIG_WMV3_CRYSTALHD_DECODER
|
1004 |
AVCodec ff_wmv3_crystalhd_decoder = { |
1005 |
.name = "wmv3_crystalhd",
|
1006 |
.type = AVMEDIA_TYPE_VIDEO, |
1007 |
.id = CODEC_ID_WMV3, |
1008 |
.priv_data_size = sizeof(CHDContext),
|
1009 |
.init = init, |
1010 |
.close = uninit, |
1011 |
.decode = decode, |
1012 |
.capabilities = CODEC_CAP_DR1 | CODEC_CAP_DELAY | CODEC_CAP_EXPERIMENTAL, |
1013 |
.flush = flush, |
1014 |
.long_name = NULL_IF_CONFIG_SMALL("Windows Media Video 9 (CrystalHD acceleration)"),
|
1015 |
.pix_fmts = (const enum PixelFormat[]){PIX_FMT_YUYV422, PIX_FMT_NONE}, |
1016 |
}; |
1017 |
#endif
|