History

Support more Avid Meridien / AVUI samples.

Fixes ticket #1288.

Carl Eugen Hoyos committed 14 years ago

Commit 183596f1 parent 88d5cfe1 file · +31 −14Browse files

Unified · Split

libavcodec/avuidec.c+31−14
@@ -41,19 +41,31 @@ static int avui_decode_frame(AVCodecContext *avctx, void *data, · 40 unmodified lines
4141 {
4242 AVFrame *pic = avctx->coded_frame;
4343 const uint8_t *src = avpkt->data;
44− const uint8_t *srca = src + 2 * (avctx->height + 16) * avctx->width + 9;
44+ const uint8_t *srca;
4545 uint8_t *y, *u, *v, *a;
46− int transparent = 0, i, j, k;
46+ int transparent, interlaced = 1, skip[2], i, j, k;
4747
4848 if (pic->data[0])
4949 avctx->release_buffer(avctx, pic);
5050
51− if (avpkt->size < 2 * avctx->width * (avctx->height + 16) + 4) {
51+ if (!memcmp(&avctx->extradata[4], "APRGAPRG0001", 12) &&
52+ avctx->extradata_size >= 24)
53+ interlaced = avctx->extradata[19] != 1;
54+ skip[0] = skip[1] = 16;
55+ if (avctx->height == 486) {
56+ skip[0] = 8;
57+ skip[1] = 12;
58+ }
59+ if (avpkt->size < avctx->width * (2 * avctx->height + skip[0] + skip[1])
60+ + 4 * interlaced) {
5261 av_log(avctx, AV_LOG_ERROR, "Insufficient input data.\n");
5362 return AVERROR(EINVAL);
5463 }
55− if (avpkt->size >= 4 * avctx->width * (avctx->height + 16) + 13)
56− transparent = 1;
64+ transparent = avctx->bits_per_coded_sample == 32 &&
65+ avpkt->size >= (2 * avctx->height + skip[0] + skip[1]) *
66+ 2 * avctx->width + 4 + 8 * interlaced;
67+ srca = src + (2 * avctx->height + skip[0] + skip[1]) * avctx->width
68+ + 5 + interlaced * 4;
5769
5870 pic->reference = 0;
5971
@@ -65,16 +77,21 @@ static int avui_decode_frame(AVCodecContext *avctx, void *data, · 5 unmodified lines
6577 pic->key_frame = 1;
6678 pic->pict_type = AV_PICTURE_TYPE_I;
6779
68− for (i = 0; i < 2; i++) {
69− src += avctx->width * 16;
70− srca += avctx->width * 16;
80+ if (!interlaced) {
81+ src += avctx->width * skip[1];
82+ srca += avctx->width * skip[1];
83+ }
84+
85+ for (i = 0; i < interlaced + 1; i++) {
86+ src += avctx->width * skip[i];
87+ srca += avctx->width * skip[i];
7188 y = pic->data[0] + i * pic->linesize[0];
7289 u = pic->data[1] + i * pic->linesize[1];
7390 v = pic->data[2] + i * pic->linesize[2];
7491 a = pic->data[3] + i * pic->linesize[3];
7592
76− for (j = 0; j < (avctx->height + 1) >> 1; j++) {
77− for (k = 0; k < (avctx->width + 1) >> 1; k++) {
93+ for (j = 0; j < avctx->height >> interlaced; j++) {
94+ for (k = 0; k < avctx->width >> 1; k++) {
7895 u[ k ] = *src++;
7996 y[2 * k ] = *src++;
8097 a[2 * k ] = 0xFF - (transparent ? *srca++ : 0);
@@ -85,10 +102,10 @@ static int avui_decode_frame(AVCodecContext *avctx, void *data, · 4 unmodified lines
85102 srca++;
86103 }
87104
88− y += 2 * pic->linesize[0];
89− u += 2 * pic->linesize[1];
90− v += 2 * pic->linesize[2];
91− a += 2 * pic->linesize[3];
105+ y += (interlaced + 1) * pic->linesize[0];
106+ u += (interlaced + 1) * pic->linesize[1];
107+ v += (interlaced + 1) * pic->linesize[2];
108+ a += (interlaced + 1) * pic->linesize[3];
92109 }
93110 src += 4;
94111 srca += 4;

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t