Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
Michael Niedermayer authored on 2013/04/15 19:07:12... | ... |
@@ -340,6 +340,7 @@ static int dfa_decode_frame(AVCodecContext *avctx, |
340 | 340 |
uint8_t *dst; |
341 | 341 |
int ret; |
342 | 342 |
int i, pal_elems; |
343 |
+ int version = avctx->extradata_size==2 ? AV_RL16(avctx->extradata) : 0; |
|
343 | 344 |
|
344 | 345 |
if ((ret = ff_get_buffer(avctx, frame, 0)) < 0) |
345 | 346 |
return ret; |
... | ... |
@@ -374,9 +375,17 @@ static int dfa_decode_frame(AVCodecContext *avctx, |
374 | 374 |
buf = s->frame_buf; |
375 | 375 |
dst = frame->data[0]; |
376 | 376 |
for (i = 0; i < avctx->height; i++) { |
377 |
- memcpy(dst, buf, avctx->width); |
|
377 |
+ if(version == 0x100) { |
|
378 |
+ int j; |
|
379 |
+ for(j = 0; j < avctx->width; j++) { |
|
380 |
+ dst[j] = buf[ (i&3)*(avctx->width /4) + (j/4) + |
|
381 |
+ ((j&3)*(avctx->height/4) + (i/4))*avctx->width]; |
|
382 |
+ } |
|
383 |
+ } else { |
|
384 |
+ memcpy(dst, buf, avctx->width); |
|
385 |
+ buf += avctx->width; |
|
386 |
+ } |
|
378 | 387 |
dst += frame->linesize[0]; |
379 |
- buf += avctx->width; |
|
380 | 388 |
} |
381 | 389 |
memcpy(frame->data[1], s->pal, sizeof(s->pal)); |
382 | 390 |
|
... | ... |
@@ -36,13 +36,15 @@ static int dfa_read_header(AVFormatContext *s) |
36 | 36 |
AVIOContext *pb = s->pb; |
37 | 37 |
AVStream *st; |
38 | 38 |
int frames; |
39 |
+ int version; |
|
39 | 40 |
uint32_t mspf; |
40 | 41 |
|
41 | 42 |
if (avio_rl32(pb) != MKTAG('D', 'F', 'I', 'A')) { |
42 | 43 |
av_log(s, AV_LOG_ERROR, "Invalid magic for DFA\n"); |
43 | 44 |
return AVERROR_INVALIDDATA; |
44 | 45 |
} |
45 |
- avio_skip(pb, 2); // unused |
|
46 |
+ |
|
47 |
+ version = avio_rl16(pb); |
|
46 | 48 |
frames = avio_rl16(pb); |
47 | 49 |
|
48 | 50 |
st = avformat_new_stream(s, NULL); |
... | ... |
@@ -62,6 +64,12 @@ static int dfa_read_header(AVFormatContext *s) |
62 | 62 |
avio_skip(pb, 128 - 16); // padding |
63 | 63 |
st->duration = frames; |
64 | 64 |
|
65 |
+ st->codec->extradata = av_malloc(2); |
|
66 |
+ st->codec->extradata_size = 2; |
|
67 |
+ AV_WL16(st->codec->extradata, version); |
|
68 |
+ if (version == 0x100) |
|
69 |
+ st->sample_aspect_ratio = (AVRational){2, 1}; |
|
70 |
+ |
|
65 | 71 |
return 0; |
66 | 72 |
} |
67 | 73 |
|