annotate dpx.c @ 10483:afad312b9989 libavcodec

Implement AMR gain function that is used by both AMR and SIPR. Based on AMR SoC code by Robert Swain and Colin McQuillan.
author vitor
date Sat, 31 Oct 2009 02:02:30 +0000
parents ee32274eb802
children d54e52670962
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
9839
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
1 /*
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
2 * DPX (.dpx) image decoder
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
3 * Copyright (c) 2009 Jimmy Christensen
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
4 *
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
5 * This file is part of FFmpeg.
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
6 *
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
7 * FFmpeg is free software; you can redistribute it and/or
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
8 * modify it under the terms of the GNU Lesser General Public
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
9 * License as published by the Free Software Foundation; either
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
10 * version 2.1 of the License, or (at your option) any later version.
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
11 *
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
12 * FFmpeg is distributed in the hope that it will be useful,
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
15 * Lesser General Public License for more details.
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
16 *
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
17 * You should have received a copy of the GNU Lesser General Public
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
18 * License along with FFmpeg; if not, write to the Free Software
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
20 */
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
21
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
22 #include "libavutil/intreadwrite.h"
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
23 #include "bytestream.h"
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
24 #include "avcodec.h"
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
25
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
26 typedef struct DPXContext {
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
27 AVFrame picture;
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
28 } DPXContext;
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
29
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
30
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
31 static unsigned int read32(const uint8_t **ptr, int is_big)
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
32 {
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
33 unsigned int temp;
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
34 if (is_big) {
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
35 temp = AV_RB32(*ptr);
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
36 } else {
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
37 temp = AV_RL32(*ptr);
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
38 }
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
39 *ptr += 4;
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
40 return temp;
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
41 }
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
42
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
43 static inline unsigned make_16bit(unsigned value)
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
44 {
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
45 // mask away invalid bits
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
46 value &= 0xFFC0;
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
47 // correctly expand to 16 bits
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
48 return value + (value >> 10);
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
49 }
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
50
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
51 static int decode_frame(AVCodecContext *avctx,
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
52 void *data,
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
53 int *data_size,
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
54 AVPacket *avpkt)
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
55 {
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
56 const uint8_t *buf = avpkt->data;
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
57 int buf_size = avpkt->size;
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
58 DPXContext *const s = avctx->priv_data;
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
59 AVFrame *picture = data;
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
60 AVFrame *const p = &s->picture;
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
61 uint8_t *ptr;
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
62
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
63 int magic_num, offset, endian;
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
64 int x, y;
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
65 int w, h, stride, bits_per_color, descriptor, elements, target_packet_size, source_packet_size;
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
66
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
67 unsigned int rgbBuffer;
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
68
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
69 magic_num = AV_RB32(buf);
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
70 buf += 4;
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
71
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
72 /* Check if the files "magic number" is "SDPX" which means it uses
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
73 * big-endian or XPDS which is for little-endian files */
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
74 if (magic_num == AV_RL32("SDPX")) {
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
75 endian = 0;
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
76 } else if (magic_num == AV_RB32("SDPX")) {
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
77 endian = 1;
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
78 } else {
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
79 av_log(avctx, AV_LOG_ERROR, "DPX marker not found\n");
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
80 return -1;
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
81 }
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
82
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
83 offset = read32(&buf, endian);
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
84 // Need to end in 0x304 offset from start of file
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
85 buf = avpkt->data + 0x304;
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
86 w = read32(&buf, endian);
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
87 h = read32(&buf, endian);
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
88
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
89 // Need to end in 0x320 to read the descriptor
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
90 buf += 20;
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
91 descriptor = buf[0];
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
92
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
93 // Need to end in 0x323 to read the bits per color
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
94 buf += 3;
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
95 bits_per_color = buf[0];
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
96
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
97 switch (descriptor) {
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
98 case 51: // RGBA
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
99 elements = 4;
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
100 break;
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
101 case 50: // RGB
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
102 elements = 3;
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
103 break;
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
104 default:
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
105 av_log(avctx, AV_LOG_ERROR, "Unsupported descriptor %d\n", descriptor);
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
106 return -1;
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
107 }
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
108
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
109 switch (bits_per_color) {
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
110 case 8:
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
111 if (elements == 4) {
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
112 avctx->pix_fmt = PIX_FMT_RGBA;
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
113 } else {
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
114 avctx->pix_fmt = PIX_FMT_RGB24;
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
115 }
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
116 source_packet_size = elements;
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
117 target_packet_size = elements;
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
118 break;
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
119 case 10:
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
120 avctx->pix_fmt = PIX_FMT_RGB48;
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
121 target_packet_size = 6;
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
122 source_packet_size = elements * 2;
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
123 break;
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
124 case 12:
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
125 case 16:
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
126 if (endian) {
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
127 avctx->pix_fmt = PIX_FMT_RGB48BE;
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
128 } else {
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
129 avctx->pix_fmt = PIX_FMT_RGB48LE;
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
130 }
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
131 target_packet_size = 6;
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
132 source_packet_size = elements * 2;
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
133 break;
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
134 default:
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
135 av_log(avctx, AV_LOG_ERROR, "Unsupported color depth : %d\n", bits_per_color);
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
136 return -1;
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
137 }
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
138
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
139 if (s->picture.data[0])
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
140 avctx->release_buffer(avctx, &s->picture);
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
141 if (avcodec_check_dimensions(avctx, w, h))
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
142 return -1;
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
143 if (w != avctx->width || h != avctx->height)
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
144 avcodec_set_dimensions(avctx, w, h);
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
145 if (avctx->get_buffer(avctx, p) < 0) {
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
146 av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
147 return -1;
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
148 }
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
149
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
150 // Move pointer to offset from start of file
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
151 buf = avpkt->data + offset;
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
152
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
153 ptr = p->data[0];
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
154 stride = p->linesize[0];
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
155
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
156 switch (bits_per_color) {
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
157 case 10:
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
158 for (x = 0; x < avctx->height; x++) {
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
159 uint16_t *dst = (uint16_t*)ptr;
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
160 for (y = 0; y < avctx->width; y++) {
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
161 rgbBuffer = read32(&buf, endian);
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
162 // Read out the 10-bit colors and convert to 16-bit
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
163 *dst++ = make_16bit(rgbBuffer >> 16);
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
164 *dst++ = make_16bit(rgbBuffer >> 6);
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
165 *dst++ = make_16bit(rgbBuffer << 4);
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
166 }
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
167 ptr += stride;
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
168 }
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
169 break;
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
170 case 8:
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
171 case 12: // Treat 12-bit as 16-bit
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
172 case 16:
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
173 if (source_packet_size == target_packet_size) {
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
174 for (x = 0; x < avctx->height; x++) {
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
175 memcpy(ptr, buf, target_packet_size*avctx->width);
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
176 ptr += stride;
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
177 buf += source_packet_size*avctx->width;
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
178 }
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
179 } else {
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
180 for (x = 0; x < avctx->height; x++) {
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
181 uint8_t *dst = ptr;
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
182 for (y = 0; y < avctx->width; y++) {
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
183 memcpy(dst, buf, target_packet_size);
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
184 dst += target_packet_size;
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
185 buf += source_packet_size;
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
186 }
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
187 ptr += stride;
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
188 }
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
189 }
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
190 break;
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
191 }
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
192
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
193 *picture = s->picture;
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
194 *data_size = sizeof(AVPicture);
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
195
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
196 return buf_size;
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
197 }
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
198
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
199 static av_cold int decode_init(AVCodecContext *avctx)
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
200 {
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
201 DPXContext *s = avctx->priv_data;
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
202 avcodec_get_frame_defaults(&s->picture);
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
203 avctx->coded_frame = &s->picture;
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
204 return 0;
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
205 }
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
206
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
207 static av_cold int decode_end(AVCodecContext *avctx)
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
208 {
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
209 DPXContext *s = avctx->priv_data;
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
210 if (s->picture.data[0])
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
211 avctx->release_buffer(avctx, &s->picture);
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
212
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
213 return 0;
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
214 }
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
215
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
216 AVCodec dpx_decoder = {
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
217 "dpx",
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
218 CODEC_TYPE_VIDEO,
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
219 CODEC_ID_DPX,
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
220 sizeof(DPXContext),
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
221 decode_init,
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
222 NULL,
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
223 decode_end,
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
224 decode_frame,
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
225 0,
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
226 NULL,
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
227 .long_name = NULL_IF_CONFIG_SMALL("DPX image"),
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
228 };