Mercurial > libavcodec.hg
annotate qdrw.c @ 9521:d8e5002210cb libavcodec
Remove some useless assignments and variables found by Clang
author | kostya |
---|---|
date | Tue, 21 Apr 2009 05:24:50 +0000 |
parents | 54bc8a2727b0 |
children | d7ed9dcc78e3 |
rev | line source |
---|---|
2275
c443a6af19a7
support for Sierra Online audio files and Apple QuickDraw codec,
melanson
parents:
diff
changeset
|
1 /* |
c443a6af19a7
support for Sierra Online audio files and Apple QuickDraw codec,
melanson
parents:
diff
changeset
|
2 * QuickDraw (qdrw) codec |
c443a6af19a7
support for Sierra Online audio files and Apple QuickDraw codec,
melanson
parents:
diff
changeset
|
3 * Copyright (c) 2004 Konstantin Shishkov |
c443a6af19a7
support for Sierra Online audio files and Apple QuickDraw codec,
melanson
parents:
diff
changeset
|
4 * |
3947
c8c591fe26f8
Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents:
3800
diff
changeset
|
5 * This file is part of FFmpeg. |
c8c591fe26f8
Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents:
3800
diff
changeset
|
6 * |
c8c591fe26f8
Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents:
3800
diff
changeset
|
7 * FFmpeg is free software; you can redistribute it and/or |
2275
c443a6af19a7
support for Sierra Online audio files and Apple QuickDraw codec,
melanson
parents:
diff
changeset
|
8 * modify it under the terms of the GNU Lesser General Public |
c443a6af19a7
support for Sierra Online audio files and Apple QuickDraw codec,
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:
3800
diff
changeset
|
10 * version 2.1 of the License, or (at your option) any later version. |
2275
c443a6af19a7
support for Sierra Online audio files and Apple QuickDraw codec,
melanson
parents:
diff
changeset
|
11 * |
3947
c8c591fe26f8
Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents:
3800
diff
changeset
|
12 * FFmpeg is distributed in the hope that it will be useful, |
2275
c443a6af19a7
support for Sierra Online audio files and Apple QuickDraw codec,
melanson
parents:
diff
changeset
|
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
c443a6af19a7
support for Sierra Online audio files and Apple QuickDraw codec,
melanson
parents:
diff
changeset
|
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
c443a6af19a7
support for Sierra Online audio files and Apple QuickDraw codec,
melanson
parents:
diff
changeset
|
15 * Lesser General Public License for more details. |
c443a6af19a7
support for Sierra Online audio files and Apple QuickDraw codec,
melanson
parents:
diff
changeset
|
16 * |
c443a6af19a7
support for Sierra Online audio files and Apple QuickDraw codec,
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:
3800
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:
2967
diff
changeset
|
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
2275
c443a6af19a7
support for Sierra Online audio files and Apple QuickDraw codec,
melanson
parents:
diff
changeset
|
20 */ |
2967 | 21 |
2275
c443a6af19a7
support for Sierra Online audio files and Apple QuickDraw codec,
melanson
parents:
diff
changeset
|
22 /** |
8718
e9d9d946f213
Use full internal pathname in doxygen @file directives.
diego
parents:
8573
diff
changeset
|
23 * @file libavcodec/qdrw.c |
2275
c443a6af19a7
support for Sierra Online audio files and Apple QuickDraw codec,
melanson
parents:
diff
changeset
|
24 * Apple QuickDraw codec. |
c443a6af19a7
support for Sierra Online audio files and Apple QuickDraw codec,
melanson
parents:
diff
changeset
|
25 */ |
2967 | 26 |
8573
2acf0ae7b041
Fix build: Add intreadwrite.h and bswap.h #includes where necessary.
diego
parents:
7040
diff
changeset
|
27 #include "libavutil/intreadwrite.h" |
2275
c443a6af19a7
support for Sierra Online audio files and Apple QuickDraw codec,
melanson
parents:
diff
changeset
|
28 #include "avcodec.h" |
c443a6af19a7
support for Sierra Online audio files and Apple QuickDraw codec,
melanson
parents:
diff
changeset
|
29 |
c443a6af19a7
support for Sierra Online audio files and Apple QuickDraw codec,
melanson
parents:
diff
changeset
|
30 typedef struct QdrawContext{ |
c443a6af19a7
support for Sierra Online audio files and Apple QuickDraw codec,
melanson
parents:
diff
changeset
|
31 AVCodecContext *avctx; |
c443a6af19a7
support for Sierra Online audio files and Apple QuickDraw codec,
melanson
parents:
diff
changeset
|
32 AVFrame pic; |
c443a6af19a7
support for Sierra Online audio files and Apple QuickDraw codec,
melanson
parents:
diff
changeset
|
33 } QdrawContext; |
c443a6af19a7
support for Sierra Online audio files and Apple QuickDraw codec,
melanson
parents:
diff
changeset
|
34 |
2967 | 35 static int decode_frame(AVCodecContext *avctx, |
2275
c443a6af19a7
support for Sierra Online audio files and Apple QuickDraw codec,
melanson
parents:
diff
changeset
|
36 void *data, int *data_size, |
9355
54bc8a2727b0
Implement avcodec_decode_video2(), _audio3() and _subtitle2() which takes an
rbultje
parents:
8718
diff
changeset
|
37 AVPacket *avpkt) |
2275
c443a6af19a7
support for Sierra Online audio files and Apple QuickDraw codec,
melanson
parents:
diff
changeset
|
38 { |
9355
54bc8a2727b0
Implement avcodec_decode_video2(), _audio3() and _subtitle2() which takes an
rbultje
parents:
8718
diff
changeset
|
39 const uint8_t *buf = avpkt->data; |
54bc8a2727b0
Implement avcodec_decode_video2(), _audio3() and _subtitle2() which takes an
rbultje
parents:
8718
diff
changeset
|
40 int buf_size = avpkt->size; |
2275
c443a6af19a7
support for Sierra Online audio files and Apple QuickDraw codec,
melanson
parents:
diff
changeset
|
41 QdrawContext * const a = avctx->priv_data; |
c443a6af19a7
support for Sierra Online audio files and Apple QuickDraw codec,
melanson
parents:
diff
changeset
|
42 AVFrame * const p= (AVFrame*)&a->pic; |
c443a6af19a7
support for Sierra Online audio files and Apple QuickDraw codec,
melanson
parents:
diff
changeset
|
43 uint8_t* outdata; |
c443a6af19a7
support for Sierra Online audio files and Apple QuickDraw codec,
melanson
parents:
diff
changeset
|
44 int colors; |
c443a6af19a7
support for Sierra Online audio files and Apple QuickDraw codec,
melanson
parents:
diff
changeset
|
45 int i; |
4787 | 46 uint32_t *pal; |
47 int r, g, b; | |
2967 | 48 |
2275
c443a6af19a7
support for Sierra Online audio files and Apple QuickDraw codec,
melanson
parents:
diff
changeset
|
49 if(p->data[0]) |
c443a6af19a7
support for Sierra Online audio files and Apple QuickDraw codec,
melanson
parents:
diff
changeset
|
50 avctx->release_buffer(avctx, p); |
c443a6af19a7
support for Sierra Online audio files and Apple QuickDraw codec,
melanson
parents:
diff
changeset
|
51 |
c443a6af19a7
support for Sierra Online audio files and Apple QuickDraw codec,
melanson
parents:
diff
changeset
|
52 p->reference= 0; |
c443a6af19a7
support for Sierra Online audio files and Apple QuickDraw codec,
melanson
parents:
diff
changeset
|
53 if(avctx->get_buffer(avctx, p) < 0){ |
c443a6af19a7
support for Sierra Online audio files and Apple QuickDraw codec,
melanson
parents:
diff
changeset
|
54 av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n"); |
c443a6af19a7
support for Sierra Online audio files and Apple QuickDraw codec,
melanson
parents:
diff
changeset
|
55 return -1; |
c443a6af19a7
support for Sierra Online audio files and Apple QuickDraw codec,
melanson
parents:
diff
changeset
|
56 } |
6450 | 57 p->pict_type= FF_I_TYPE; |
2275
c443a6af19a7
support for Sierra Online audio files and Apple QuickDraw codec,
melanson
parents:
diff
changeset
|
58 p->key_frame= 1; |
c443a6af19a7
support for Sierra Online audio files and Apple QuickDraw codec,
melanson
parents:
diff
changeset
|
59 |
c443a6af19a7
support for Sierra Online audio files and Apple QuickDraw codec,
melanson
parents:
diff
changeset
|
60 outdata = a->pic.data[0]; |
2967 | 61 |
2275
c443a6af19a7
support for Sierra Online audio files and Apple QuickDraw codec,
melanson
parents:
diff
changeset
|
62 buf += 0x68; /* jump to palette */ |
4364 | 63 colors = AV_RB32(buf); |
2275
c443a6af19a7
support for Sierra Online audio files and Apple QuickDraw codec,
melanson
parents:
diff
changeset
|
64 buf += 4; |
2967 | 65 |
2275
c443a6af19a7
support for Sierra Online audio files and Apple QuickDraw codec,
melanson
parents:
diff
changeset
|
66 if(colors < 0 || colors > 256) { |
c443a6af19a7
support for Sierra Online audio files and Apple QuickDraw codec,
melanson
parents:
diff
changeset
|
67 av_log(avctx, AV_LOG_ERROR, "Error color count - %i(0x%X)\n", colors, colors); |
c443a6af19a7
support for Sierra Online audio files and Apple QuickDraw codec,
melanson
parents:
diff
changeset
|
68 return -1; |
c443a6af19a7
support for Sierra Online audio files and Apple QuickDraw codec,
melanson
parents:
diff
changeset
|
69 } |
2967 | 70 |
4787 | 71 pal = (uint32_t*)p->data[1]; |
2275
c443a6af19a7
support for Sierra Online audio files and Apple QuickDraw codec,
melanson
parents:
diff
changeset
|
72 for (i = 0; i <= colors; i++) { |
2455 | 73 unsigned int idx; |
4364 | 74 idx = AV_RB16(buf); /* color index */ |
2275
c443a6af19a7
support for Sierra Online audio files and Apple QuickDraw codec,
melanson
parents:
diff
changeset
|
75 buf += 2; |
2967 | 76 |
2455 | 77 if (idx > 255) { |
78 av_log(avctx, AV_LOG_ERROR, "Palette index out of range: %u\n", idx); | |
79 buf += 6; | |
80 continue; | |
81 } | |
4787 | 82 r = *buf++; |
2275
c443a6af19a7
support for Sierra Online audio files and Apple QuickDraw codec,
melanson
parents:
diff
changeset
|
83 buf++; |
4787 | 84 g = *buf++; |
2275
c443a6af19a7
support for Sierra Online audio files and Apple QuickDraw codec,
melanson
parents:
diff
changeset
|
85 buf++; |
4787 | 86 b = *buf++; |
2275
c443a6af19a7
support for Sierra Online audio files and Apple QuickDraw codec,
melanson
parents:
diff
changeset
|
87 buf++; |
4787 | 88 pal[idx] = (r << 16) | (g << 8) | b; |
2275
c443a6af19a7
support for Sierra Online audio files and Apple QuickDraw codec,
melanson
parents:
diff
changeset
|
89 } |
4787 | 90 p->palette_has_changed = 1; |
2275
c443a6af19a7
support for Sierra Online audio files and Apple QuickDraw codec,
melanson
parents:
diff
changeset
|
91 |
c443a6af19a7
support for Sierra Online audio files and Apple QuickDraw codec,
melanson
parents:
diff
changeset
|
92 buf += 18; /* skip unneeded data */ |
c443a6af19a7
support for Sierra Online audio files and Apple QuickDraw codec,
melanson
parents:
diff
changeset
|
93 for (i = 0; i < avctx->height; i++) { |
c443a6af19a7
support for Sierra Online audio files and Apple QuickDraw codec,
melanson
parents:
diff
changeset
|
94 int size, left, code, pix; |
6275 | 95 const uint8_t *next; |
2275
c443a6af19a7
support for Sierra Online audio files and Apple QuickDraw codec,
melanson
parents:
diff
changeset
|
96 uint8_t *out; |
c443a6af19a7
support for Sierra Online audio files and Apple QuickDraw codec,
melanson
parents:
diff
changeset
|
97 int tsize = 0; |
2967 | 98 |
2275
c443a6af19a7
support for Sierra Online audio files and Apple QuickDraw codec,
melanson
parents:
diff
changeset
|
99 /* decode line */ |
c443a6af19a7
support for Sierra Online audio files and Apple QuickDraw codec,
melanson
parents:
diff
changeset
|
100 out = outdata; |
4364 | 101 size = AV_RB16(buf); /* size of packed line */ |
2275
c443a6af19a7
support for Sierra Online audio files and Apple QuickDraw codec,
melanson
parents:
diff
changeset
|
102 buf += 2; |
c443a6af19a7
support for Sierra Online audio files and Apple QuickDraw codec,
melanson
parents:
diff
changeset
|
103 left = size; |
c443a6af19a7
support for Sierra Online audio files and Apple QuickDraw codec,
melanson
parents:
diff
changeset
|
104 next = buf + size; |
c443a6af19a7
support for Sierra Online audio files and Apple QuickDraw codec,
melanson
parents:
diff
changeset
|
105 while (left > 0) { |
c443a6af19a7
support for Sierra Online audio files and Apple QuickDraw codec,
melanson
parents:
diff
changeset
|
106 code = *buf++; |
c443a6af19a7
support for Sierra Online audio files and Apple QuickDraw codec,
melanson
parents:
diff
changeset
|
107 if (code & 0x80 ) { /* run */ |
c443a6af19a7
support for Sierra Online audio files and Apple QuickDraw codec,
melanson
parents:
diff
changeset
|
108 pix = *buf++; |
4787 | 109 if ((out + (257 - code)) > (outdata + a->pic.linesize[0])) |
2455 | 110 break; |
4787 | 111 memset(out, pix, 257 - code); |
112 out += 257 - code; | |
2275
c443a6af19a7
support for Sierra Online audio files and Apple QuickDraw codec,
melanson
parents:
diff
changeset
|
113 tsize += 257 - code; |
c443a6af19a7
support for Sierra Online audio files and Apple QuickDraw codec,
melanson
parents:
diff
changeset
|
114 left -= 2; |
c443a6af19a7
support for Sierra Online audio files and Apple QuickDraw codec,
melanson
parents:
diff
changeset
|
115 } else { /* copy */ |
4787 | 116 if ((out + code) > (outdata + a->pic.linesize[0])) |
2455 | 117 break; |
4787 | 118 memcpy(out, buf, code + 1); |
119 out += code + 1; | |
120 buf += code + 1; | |
2275
c443a6af19a7
support for Sierra Online audio files and Apple QuickDraw codec,
melanson
parents:
diff
changeset
|
121 left -= 2 + code; |
c443a6af19a7
support for Sierra Online audio files and Apple QuickDraw codec,
melanson
parents:
diff
changeset
|
122 tsize += code + 1; |
c443a6af19a7
support for Sierra Online audio files and Apple QuickDraw codec,
melanson
parents:
diff
changeset
|
123 } |
c443a6af19a7
support for Sierra Online audio files and Apple QuickDraw codec,
melanson
parents:
diff
changeset
|
124 } |
c443a6af19a7
support for Sierra Online audio files and Apple QuickDraw codec,
melanson
parents:
diff
changeset
|
125 buf = next; |
c443a6af19a7
support for Sierra Online audio files and Apple QuickDraw codec,
melanson
parents:
diff
changeset
|
126 outdata += a->pic.linesize[0]; |
c443a6af19a7
support for Sierra Online audio files and Apple QuickDraw codec,
melanson
parents:
diff
changeset
|
127 } |
c443a6af19a7
support for Sierra Online audio files and Apple QuickDraw codec,
melanson
parents:
diff
changeset
|
128 |
c443a6af19a7
support for Sierra Online audio files and Apple QuickDraw codec,
melanson
parents:
diff
changeset
|
129 *data_size = sizeof(AVFrame); |
c443a6af19a7
support for Sierra Online audio files and Apple QuickDraw codec,
melanson
parents:
diff
changeset
|
130 *(AVFrame*)data = a->pic; |
2967 | 131 |
2275
c443a6af19a7
support for Sierra Online audio files and Apple QuickDraw codec,
melanson
parents:
diff
changeset
|
132 return buf_size; |
c443a6af19a7
support for Sierra Online audio files and Apple QuickDraw codec,
melanson
parents:
diff
changeset
|
133 } |
c443a6af19a7
support for Sierra Online audio files and Apple QuickDraw codec,
melanson
parents:
diff
changeset
|
134 |
6517
48759bfbd073
Apply 'cold' attribute to init/uninit functions in libavcodec
zuxy
parents:
6450
diff
changeset
|
135 static av_cold int decode_init(AVCodecContext *avctx){ |
2275
c443a6af19a7
support for Sierra Online audio files and Apple QuickDraw codec,
melanson
parents:
diff
changeset
|
136 // QdrawContext * const a = avctx->priv_data; |
c443a6af19a7
support for Sierra Online audio files and Apple QuickDraw codec,
melanson
parents:
diff
changeset
|
137 |
3800
9b75ab171fa9
1l: correct argument order in avcodec_check_dimensions
kostya
parents:
3036
diff
changeset
|
138 if (avcodec_check_dimensions(avctx, avctx->width, avctx->height) < 0) { |
2455 | 139 return 1; |
140 } | |
141 | |
4787 | 142 avctx->pix_fmt= PIX_FMT_PAL8; |
2275
c443a6af19a7
support for Sierra Online audio files and Apple QuickDraw codec,
melanson
parents:
diff
changeset
|
143 |
c443a6af19a7
support for Sierra Online audio files and Apple QuickDraw codec,
melanson
parents:
diff
changeset
|
144 return 0; |
c443a6af19a7
support for Sierra Online audio files and Apple QuickDraw codec,
melanson
parents:
diff
changeset
|
145 } |
c443a6af19a7
support for Sierra Online audio files and Apple QuickDraw codec,
melanson
parents:
diff
changeset
|
146 |
c443a6af19a7
support for Sierra Online audio files and Apple QuickDraw codec,
melanson
parents:
diff
changeset
|
147 AVCodec qdraw_decoder = { |
c443a6af19a7
support for Sierra Online audio files and Apple QuickDraw codec,
melanson
parents:
diff
changeset
|
148 "qdraw", |
c443a6af19a7
support for Sierra Online audio files and Apple QuickDraw codec,
melanson
parents:
diff
changeset
|
149 CODEC_TYPE_VIDEO, |
c443a6af19a7
support for Sierra Online audio files and Apple QuickDraw codec,
melanson
parents:
diff
changeset
|
150 CODEC_ID_QDRAW, |
c443a6af19a7
support for Sierra Online audio files and Apple QuickDraw codec,
melanson
parents:
diff
changeset
|
151 sizeof(QdrawContext), |
c443a6af19a7
support for Sierra Online audio files and Apple QuickDraw codec,
melanson
parents:
diff
changeset
|
152 decode_init, |
c443a6af19a7
support for Sierra Online audio files and Apple QuickDraw codec,
melanson
parents:
diff
changeset
|
153 NULL, |
c443a6af19a7
support for Sierra Online audio files and Apple QuickDraw codec,
melanson
parents:
diff
changeset
|
154 NULL, |
c443a6af19a7
support for Sierra Online audio files and Apple QuickDraw codec,
melanson
parents:
diff
changeset
|
155 decode_frame, |
c443a6af19a7
support for Sierra Online audio files and Apple QuickDraw codec,
melanson
parents:
diff
changeset
|
156 CODEC_CAP_DR1, |
7040
e943e1409077
Make AVCodec long_names definition conditional depending on CONFIG_SMALL.
stefano
parents:
6710
diff
changeset
|
157 .long_name = NULL_IF_CONFIG_SMALL("Apple QuickDraw"), |
2275
c443a6af19a7
support for Sierra Online audio files and Apple QuickDraw codec,
melanson
parents:
diff
changeset
|
158 }; |