Mercurial > libavcodec.hg
annotate aasc.c @ 10292:01e6afd0aba6 libavcodec
Remove unneeded table lookup.
author | jbr |
---|---|
date | Sun, 27 Sep 2009 06:16:49 +0000 |
parents | 4cab394c16ea |
children | 8a4984c5cacc |
rev | line source |
---|---|
2588
b6b618986f80
Autodesk Animator Studio Codec (AASC) video decoder, courtesy of
melanson
parents:
diff
changeset
|
1 /* |
6683 | 2 * Autodesk RLE Decoder |
2588
b6b618986f80
Autodesk Animator Studio Codec (AASC) video decoder, courtesy of
melanson
parents:
diff
changeset
|
3 * Copyright (C) 2005 the ffmpeg project |
b6b618986f80
Autodesk Animator Studio Codec (AASC) video decoder, courtesy of
melanson
parents:
diff
changeset
|
4 * |
3947
c8c591fe26f8
Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents:
3036
diff
changeset
|
5 * This file is part of FFmpeg. |
c8c591fe26f8
Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents:
3036
diff
changeset
|
6 * |
c8c591fe26f8
Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents:
3036
diff
changeset
|
7 * FFmpeg is free software; you can redistribute it and/or |
2588
b6b618986f80
Autodesk Animator Studio Codec (AASC) video decoder, courtesy of
melanson
parents:
diff
changeset
|
8 * modify it under the terms of the GNU Lesser General Public |
b6b618986f80
Autodesk Animator Studio Codec (AASC) video decoder, courtesy of
melanson
parents:
diff
changeset
|
9 * License as published by the Free Software Foundation; either |
3947
c8c591fe26f8
Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents:
3036
diff
changeset
|
10 * version 2.1 of the License, or (at your option) any later version. |
2588
b6b618986f80
Autodesk Animator Studio Codec (AASC) video decoder, courtesy of
melanson
parents:
diff
changeset
|
11 * |
3947
c8c591fe26f8
Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents:
3036
diff
changeset
|
12 * FFmpeg is distributed in the hope that it will be useful, |
2588
b6b618986f80
Autodesk Animator Studio Codec (AASC) video decoder, courtesy of
melanson
parents:
diff
changeset
|
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
b6b618986f80
Autodesk Animator Studio Codec (AASC) video decoder, courtesy of
melanson
parents:
diff
changeset
|
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
b6b618986f80
Autodesk Animator Studio Codec (AASC) video decoder, courtesy of
melanson
parents:
diff
changeset
|
15 * Lesser General Public License for more details. |
b6b618986f80
Autodesk Animator Studio Codec (AASC) video decoder, courtesy of
melanson
parents:
diff
changeset
|
16 * |
b6b618986f80
Autodesk Animator Studio Codec (AASC) video decoder, courtesy of
melanson
parents:
diff
changeset
|
17 * You should have received a copy of the GNU Lesser General Public |
3947
c8c591fe26f8
Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents:
3036
diff
changeset
|
18 * License along with FFmpeg; if not, write to the Free Software |
3036
0b546eab515d
Update licensing information: The FSF changed postal address.
diego
parents:
2588
diff
changeset
|
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
2588
b6b618986f80
Autodesk Animator Studio Codec (AASC) video decoder, courtesy of
melanson
parents:
diff
changeset
|
20 */ |
b6b618986f80
Autodesk Animator Studio Codec (AASC) video decoder, courtesy of
melanson
parents:
diff
changeset
|
21 |
b6b618986f80
Autodesk Animator Studio Codec (AASC) video decoder, courtesy of
melanson
parents:
diff
changeset
|
22 /** |
8718
e9d9d946f213
Use full internal pathname in doxygen @file directives.
diego
parents:
8264
diff
changeset
|
23 * @file libavcodec/aasc.c |
6683 | 24 * Autodesk RLE Video Decoder by Konstantin Shishkov |
2588
b6b618986f80
Autodesk Animator Studio Codec (AASC) video decoder, courtesy of
melanson
parents:
diff
changeset
|
25 */ |
b6b618986f80
Autodesk Animator Studio Codec (AASC) video decoder, courtesy of
melanson
parents:
diff
changeset
|
26 |
b6b618986f80
Autodesk Animator Studio Codec (AASC) video decoder, courtesy of
melanson
parents:
diff
changeset
|
27 #include <stdio.h> |
b6b618986f80
Autodesk Animator Studio Codec (AASC) video decoder, courtesy of
melanson
parents:
diff
changeset
|
28 #include <stdlib.h> |
b6b618986f80
Autodesk Animator Studio Codec (AASC) video decoder, courtesy of
melanson
parents:
diff
changeset
|
29 #include <string.h> |
b6b618986f80
Autodesk Animator Studio Codec (AASC) video decoder, courtesy of
melanson
parents:
diff
changeset
|
30 |
b6b618986f80
Autodesk Animator Studio Codec (AASC) video decoder, courtesy of
melanson
parents:
diff
changeset
|
31 #include "avcodec.h" |
b6b618986f80
Autodesk Animator Studio Codec (AASC) video decoder, courtesy of
melanson
parents:
diff
changeset
|
32 #include "dsputil.h" |
7885
f874e1d5cf07
Factorize out code used for MS RLE format decoding in different decoders.
kostya
parents:
7040
diff
changeset
|
33 #include "msrledec.h" |
2588
b6b618986f80
Autodesk Animator Studio Codec (AASC) video decoder, courtesy of
melanson
parents:
diff
changeset
|
34 |
b6b618986f80
Autodesk Animator Studio Codec (AASC) video decoder, courtesy of
melanson
parents:
diff
changeset
|
35 typedef struct AascContext { |
b6b618986f80
Autodesk Animator Studio Codec (AASC) video decoder, courtesy of
melanson
parents:
diff
changeset
|
36 AVCodecContext *avctx; |
b6b618986f80
Autodesk Animator Studio Codec (AASC) video decoder, courtesy of
melanson
parents:
diff
changeset
|
37 AVFrame frame; |
b6b618986f80
Autodesk Animator Studio Codec (AASC) video decoder, courtesy of
melanson
parents:
diff
changeset
|
38 } AascContext; |
b6b618986f80
Autodesk Animator Studio Codec (AASC) video decoder, courtesy of
melanson
parents:
diff
changeset
|
39 |
b6b618986f80
Autodesk Animator Studio Codec (AASC) video decoder, courtesy of
melanson
parents:
diff
changeset
|
40 #define FETCH_NEXT_STREAM_BYTE() \ |
b6b618986f80
Autodesk Animator Studio Codec (AASC) video decoder, courtesy of
melanson
parents:
diff
changeset
|
41 if (stream_ptr >= buf_size) \ |
b6b618986f80
Autodesk Animator Studio Codec (AASC) video decoder, courtesy of
melanson
parents:
diff
changeset
|
42 { \ |
b6b618986f80
Autodesk Animator Studio Codec (AASC) video decoder, courtesy of
melanson
parents:
diff
changeset
|
43 av_log(s->avctx, AV_LOG_ERROR, " AASC: stream ptr just went out of bounds (fetch)\n"); \ |
b6b618986f80
Autodesk Animator Studio Codec (AASC) video decoder, courtesy of
melanson
parents:
diff
changeset
|
44 break; \ |
b6b618986f80
Autodesk Animator Studio Codec (AASC) video decoder, courtesy of
melanson
parents:
diff
changeset
|
45 } \ |
b6b618986f80
Autodesk Animator Studio Codec (AASC) video decoder, courtesy of
melanson
parents:
diff
changeset
|
46 stream_byte = buf[stream_ptr++]; |
b6b618986f80
Autodesk Animator Studio Codec (AASC) video decoder, courtesy of
melanson
parents:
diff
changeset
|
47 |
6517
48759bfbd073
Apply 'cold' attribute to init/uninit functions in libavcodec
zuxy
parents:
6221
diff
changeset
|
48 static av_cold int aasc_decode_init(AVCodecContext *avctx) |
2588
b6b618986f80
Autodesk Animator Studio Codec (AASC) video decoder, courtesy of
melanson
parents:
diff
changeset
|
49 { |
4827 | 50 AascContext *s = avctx->priv_data; |
2588
b6b618986f80
Autodesk Animator Studio Codec (AASC) video decoder, courtesy of
melanson
parents:
diff
changeset
|
51 |
b6b618986f80
Autodesk Animator Studio Codec (AASC) video decoder, courtesy of
melanson
parents:
diff
changeset
|
52 s->avctx = avctx; |
b6b618986f80
Autodesk Animator Studio Codec (AASC) video decoder, courtesy of
melanson
parents:
diff
changeset
|
53 |
b6b618986f80
Autodesk Animator Studio Codec (AASC) video decoder, courtesy of
melanson
parents:
diff
changeset
|
54 avctx->pix_fmt = PIX_FMT_BGR24; |
b6b618986f80
Autodesk Animator Studio Codec (AASC) video decoder, courtesy of
melanson
parents:
diff
changeset
|
55 |
b6b618986f80
Autodesk Animator Studio Codec (AASC) video decoder, courtesy of
melanson
parents:
diff
changeset
|
56 return 0; |
b6b618986f80
Autodesk Animator Studio Codec (AASC) video decoder, courtesy of
melanson
parents:
diff
changeset
|
57 } |
b6b618986f80
Autodesk Animator Studio Codec (AASC) video decoder, courtesy of
melanson
parents:
diff
changeset
|
58 |
b6b618986f80
Autodesk Animator Studio Codec (AASC) video decoder, courtesy of
melanson
parents:
diff
changeset
|
59 static int aasc_decode_frame(AVCodecContext *avctx, |
b6b618986f80
Autodesk Animator Studio Codec (AASC) video decoder, courtesy of
melanson
parents:
diff
changeset
|
60 void *data, int *data_size, |
9355
54bc8a2727b0
Implement avcodec_decode_video2(), _audio3() and _subtitle2() which takes an
rbultje
parents:
8720
diff
changeset
|
61 AVPacket *avpkt) |
2588
b6b618986f80
Autodesk Animator Studio Codec (AASC) video decoder, courtesy of
melanson
parents:
diff
changeset
|
62 { |
9355
54bc8a2727b0
Implement avcodec_decode_video2(), _audio3() and _subtitle2() which takes an
rbultje
parents:
8720
diff
changeset
|
63 const uint8_t *buf = avpkt->data; |
54bc8a2727b0
Implement avcodec_decode_video2(), _audio3() and _subtitle2() which takes an
rbultje
parents:
8720
diff
changeset
|
64 int buf_size = avpkt->size; |
4827 | 65 AascContext *s = avctx->priv_data; |
8264 | 66 int compr, i, stride; |
2588
b6b618986f80
Autodesk Animator Studio Codec (AASC) video decoder, courtesy of
melanson
parents:
diff
changeset
|
67 |
b6b618986f80
Autodesk Animator Studio Codec (AASC) video decoder, courtesy of
melanson
parents:
diff
changeset
|
68 s->frame.reference = 1; |
b6b618986f80
Autodesk Animator Studio Codec (AASC) video decoder, courtesy of
melanson
parents:
diff
changeset
|
69 s->frame.buffer_hints = FF_BUFFER_HINTS_VALID | FF_BUFFER_HINTS_PRESERVE | FF_BUFFER_HINTS_REUSABLE; |
b6b618986f80
Autodesk Animator Studio Codec (AASC) video decoder, courtesy of
melanson
parents:
diff
changeset
|
70 if (avctx->reget_buffer(avctx, &s->frame)) { |
b6b618986f80
Autodesk Animator Studio Codec (AASC) video decoder, courtesy of
melanson
parents:
diff
changeset
|
71 av_log(avctx, AV_LOG_ERROR, "reget_buffer() failed\n"); |
b6b618986f80
Autodesk Animator Studio Codec (AASC) video decoder, courtesy of
melanson
parents:
diff
changeset
|
72 return -1; |
b6b618986f80
Autodesk Animator Studio Codec (AASC) video decoder, courtesy of
melanson
parents:
diff
changeset
|
73 } |
b6b618986f80
Autodesk Animator Studio Codec (AASC) video decoder, courtesy of
melanson
parents:
diff
changeset
|
74 |
8264 | 75 compr = AV_RL32(buf); |
76 buf += 4; | |
77 buf_size -= 4; | |
78 switch(compr){ | |
79 case 0: | |
80 stride = (avctx->width * 3 + 3) & ~3; | |
81 for(i = avctx->height - 1; i >= 0; i--){ | |
82 memcpy(s->frame.data[0] + i*s->frame.linesize[0], buf, avctx->width*3); | |
83 buf += stride; | |
84 } | |
85 break; | |
86 case 1: | |
8720
052c676c433b
Silence useless compiler warning when passing AVFrame* instead of AVPicture*
kostya
parents:
8718
diff
changeset
|
87 ff_msrle_decode(avctx, (AVPicture*)&s->frame, 8, buf - 4, buf_size + 4); |
8264 | 88 break; |
89 default: | |
90 av_log(avctx, AV_LOG_ERROR, "Unknown compression type %d\n", compr); | |
91 return -1; | |
92 } | |
2588
b6b618986f80
Autodesk Animator Studio Codec (AASC) video decoder, courtesy of
melanson
parents:
diff
changeset
|
93 |
b6b618986f80
Autodesk Animator Studio Codec (AASC) video decoder, courtesy of
melanson
parents:
diff
changeset
|
94 *data_size = sizeof(AVFrame); |
b6b618986f80
Autodesk Animator Studio Codec (AASC) video decoder, courtesy of
melanson
parents:
diff
changeset
|
95 *(AVFrame*)data = s->frame; |
b6b618986f80
Autodesk Animator Studio Codec (AASC) video decoder, courtesy of
melanson
parents:
diff
changeset
|
96 |
b6b618986f80
Autodesk Animator Studio Codec (AASC) video decoder, courtesy of
melanson
parents:
diff
changeset
|
97 /* report that the buffer was completely consumed */ |
b6b618986f80
Autodesk Animator Studio Codec (AASC) video decoder, courtesy of
melanson
parents:
diff
changeset
|
98 return buf_size; |
b6b618986f80
Autodesk Animator Studio Codec (AASC) video decoder, courtesy of
melanson
parents:
diff
changeset
|
99 } |
b6b618986f80
Autodesk Animator Studio Codec (AASC) video decoder, courtesy of
melanson
parents:
diff
changeset
|
100 |
6517
48759bfbd073
Apply 'cold' attribute to init/uninit functions in libavcodec
zuxy
parents:
6221
diff
changeset
|
101 static av_cold int aasc_decode_end(AVCodecContext *avctx) |
2588
b6b618986f80
Autodesk Animator Studio Codec (AASC) video decoder, courtesy of
melanson
parents:
diff
changeset
|
102 { |
4827 | 103 AascContext *s = avctx->priv_data; |
2588
b6b618986f80
Autodesk Animator Studio Codec (AASC) video decoder, courtesy of
melanson
parents:
diff
changeset
|
104 |
b6b618986f80
Autodesk Animator Studio Codec (AASC) video decoder, courtesy of
melanson
parents:
diff
changeset
|
105 /* release the last frame */ |
b6b618986f80
Autodesk Animator Studio Codec (AASC) video decoder, courtesy of
melanson
parents:
diff
changeset
|
106 if (s->frame.data[0]) |
b6b618986f80
Autodesk Animator Studio Codec (AASC) video decoder, courtesy of
melanson
parents:
diff
changeset
|
107 avctx->release_buffer(avctx, &s->frame); |
b6b618986f80
Autodesk Animator Studio Codec (AASC) video decoder, courtesy of
melanson
parents:
diff
changeset
|
108 |
b6b618986f80
Autodesk Animator Studio Codec (AASC) video decoder, courtesy of
melanson
parents:
diff
changeset
|
109 return 0; |
b6b618986f80
Autodesk Animator Studio Codec (AASC) video decoder, courtesy of
melanson
parents:
diff
changeset
|
110 } |
b6b618986f80
Autodesk Animator Studio Codec (AASC) video decoder, courtesy of
melanson
parents:
diff
changeset
|
111 |
b6b618986f80
Autodesk Animator Studio Codec (AASC) video decoder, courtesy of
melanson
parents:
diff
changeset
|
112 AVCodec aasc_decoder = { |
b6b618986f80
Autodesk Animator Studio Codec (AASC) video decoder, courtesy of
melanson
parents:
diff
changeset
|
113 "aasc", |
b6b618986f80
Autodesk Animator Studio Codec (AASC) video decoder, courtesy of
melanson
parents:
diff
changeset
|
114 CODEC_TYPE_VIDEO, |
b6b618986f80
Autodesk Animator Studio Codec (AASC) video decoder, courtesy of
melanson
parents:
diff
changeset
|
115 CODEC_ID_AASC, |
b6b618986f80
Autodesk Animator Studio Codec (AASC) video decoder, courtesy of
melanson
parents:
diff
changeset
|
116 sizeof(AascContext), |
b6b618986f80
Autodesk Animator Studio Codec (AASC) video decoder, courtesy of
melanson
parents:
diff
changeset
|
117 aasc_decode_init, |
b6b618986f80
Autodesk Animator Studio Codec (AASC) video decoder, courtesy of
melanson
parents:
diff
changeset
|
118 NULL, |
b6b618986f80
Autodesk Animator Studio Codec (AASC) video decoder, courtesy of
melanson
parents:
diff
changeset
|
119 aasc_decode_end, |
b6b618986f80
Autodesk Animator Studio Codec (AASC) video decoder, courtesy of
melanson
parents:
diff
changeset
|
120 aasc_decode_frame, |
b6b618986f80
Autodesk Animator Studio Codec (AASC) video decoder, courtesy of
melanson
parents:
diff
changeset
|
121 CODEC_CAP_DR1, |
7040
e943e1409077
Make AVCodec long_names definition conditional depending on CONFIG_SMALL.
stefano
parents:
6710
diff
changeset
|
122 .long_name = NULL_IF_CONFIG_SMALL("Autodesk RLE"), |
2588
b6b618986f80
Autodesk Animator Studio Codec (AASC) video decoder, courtesy of
melanson
parents:
diff
changeset
|
123 }; |