annotate dpx.c @ 11582:23cad4157bfb libavcodec

Make code using 1d-DCT consistent with the API change
author vitor
date Sat, 03 Apr 2010 15:04:15 +0000
parents 8a4984c5cacc
children 914f484bb476
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;
10691
d54e52670962 Set bits_per_raw_sample appropriately in dpx decoder.
reimar
parents: 9839
diff changeset
95 avctx->bits_per_raw_sample =
9839
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
96 bits_per_color = buf[0];
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
97
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
98 switch (descriptor) {
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
99 case 51: // RGBA
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
100 elements = 4;
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
101 break;
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
102 case 50: // RGB
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
103 elements = 3;
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
104 break;
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
105 default:
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
106 av_log(avctx, AV_LOG_ERROR, "Unsupported descriptor %d\n", descriptor);
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
107 return -1;
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
108 }
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
109
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
110 switch (bits_per_color) {
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
111 case 8:
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
112 if (elements == 4) {
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
113 avctx->pix_fmt = PIX_FMT_RGBA;
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
114 } else {
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
115 avctx->pix_fmt = PIX_FMT_RGB24;
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
116 }
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
117 source_packet_size = elements;
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
118 target_packet_size = elements;
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
119 break;
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
120 case 10:
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
121 avctx->pix_fmt = PIX_FMT_RGB48;
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
122 target_packet_size = 6;
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
123 source_packet_size = elements * 2;
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
124 break;
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
125 case 12:
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
126 case 16:
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
127 if (endian) {
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
128 avctx->pix_fmt = PIX_FMT_RGB48BE;
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
129 } else {
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
130 avctx->pix_fmt = PIX_FMT_RGB48LE;
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
131 }
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
132 target_packet_size = 6;
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
133 source_packet_size = elements * 2;
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
134 break;
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
135 default:
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
136 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
137 return -1;
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
138 }
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
139
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
140 if (s->picture.data[0])
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
141 avctx->release_buffer(avctx, &s->picture);
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
142 if (avcodec_check_dimensions(avctx, w, h))
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
143 return -1;
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
144 if (w != avctx->width || h != avctx->height)
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
145 avcodec_set_dimensions(avctx, w, h);
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
146 if (avctx->get_buffer(avctx, p) < 0) {
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
147 av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
148 return -1;
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
149 }
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
150
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
151 // Move pointer to offset from start of file
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
152 buf = avpkt->data + offset;
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
153
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
154 ptr = p->data[0];
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
155 stride = p->linesize[0];
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
156
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
157 switch (bits_per_color) {
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
158 case 10:
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
159 for (x = 0; x < avctx->height; x++) {
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
160 uint16_t *dst = (uint16_t*)ptr;
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
161 for (y = 0; y < avctx->width; y++) {
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
162 rgbBuffer = read32(&buf, endian);
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
163 // Read out the 10-bit colors and convert to 16-bit
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
164 *dst++ = make_16bit(rgbBuffer >> 16);
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
165 *dst++ = make_16bit(rgbBuffer >> 6);
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
166 *dst++ = make_16bit(rgbBuffer << 4);
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
167 }
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
168 ptr += stride;
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
169 }
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
170 break;
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
171 case 8:
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
172 case 12: // Treat 12-bit as 16-bit
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
173 case 16:
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
174 if (source_packet_size == target_packet_size) {
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
175 for (x = 0; x < avctx->height; x++) {
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
176 memcpy(ptr, buf, target_packet_size*avctx->width);
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
177 ptr += stride;
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
178 buf += source_packet_size*avctx->width;
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
179 }
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
180 } else {
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
181 for (x = 0; x < avctx->height; x++) {
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
182 uint8_t *dst = ptr;
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
183 for (y = 0; y < avctx->width; y++) {
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
184 memcpy(dst, buf, target_packet_size);
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
185 dst += target_packet_size;
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
186 buf += source_packet_size;
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
187 }
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
188 ptr += stride;
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
189 }
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
190 }
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
191 break;
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
192 }
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
193
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
194 *picture = s->picture;
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
195 *data_size = sizeof(AVPicture);
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
196
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
197 return buf_size;
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
198 }
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
199
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
200 static av_cold int decode_init(AVCodecContext *avctx)
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
201 {
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
202 DPXContext *s = avctx->priv_data;
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
203 avcodec_get_frame_defaults(&s->picture);
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
204 avctx->coded_frame = &s->picture;
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
205 return 0;
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
206 }
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
207
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
208 static av_cold int decode_end(AVCodecContext *avctx)
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
209 {
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
210 DPXContext *s = avctx->priv_data;
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
211 if (s->picture.data[0])
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
212 avctx->release_buffer(avctx, &s->picture);
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
213
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
214 return 0;
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
215 }
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
216
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
217 AVCodec dpx_decoder = {
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
218 "dpx",
11560
8a4984c5cacc Define AVMediaType enum, and use it instead of enum CodecType, which
stefano
parents: 10691
diff changeset
219 AVMEDIA_TYPE_VIDEO,
9839
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
220 CODEC_ID_DPX,
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
221 sizeof(DPXContext),
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
222 decode_init,
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
223 NULL,
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
224 decode_end,
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
225 decode_frame,
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
226 0,
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
227 NULL,
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
228 .long_name = NULL_IF_CONFIG_SMALL("DPX image"),
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
229 };