annotate dpx.c @ 12522:776789af0304 libavcodec

Move AVOptions from libavcodec to libavutil
author michael
date Sun, 26 Sep 2010 14:25:22 +0000
parents ffb3668ff7af
children
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"
12372
914f484bb476 Remove use of the deprecated function avcodec_check_dimensions(), use
stefano
parents: 11560
diff changeset
23 #include "libavcore/imgutils.h"
9839
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
24 #include "bytestream.h"
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
25 #include "avcodec.h"
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
26
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
27 typedef struct DPXContext {
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
28 AVFrame picture;
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
29 } DPXContext;
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
30
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
31
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
32 static unsigned int read32(const uint8_t **ptr, int is_big)
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
33 {
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
34 unsigned int temp;
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
35 if (is_big) {
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
36 temp = AV_RB32(*ptr);
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
37 } else {
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
38 temp = AV_RL32(*ptr);
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
39 }
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
40 *ptr += 4;
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
41 return temp;
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
42 }
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
43
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
44 static inline unsigned make_16bit(unsigned value)
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
45 {
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
46 // mask away invalid bits
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
47 value &= 0xFFC0;
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
48 // correctly expand to 16 bits
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
49 return value + (value >> 10);
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
50 }
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
51
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
52 static int decode_frame(AVCodecContext *avctx,
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
53 void *data,
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
54 int *data_size,
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
55 AVPacket *avpkt)
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
56 {
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
57 const uint8_t *buf = avpkt->data;
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
58 int buf_size = avpkt->size;
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
59 DPXContext *const s = avctx->priv_data;
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
60 AVFrame *picture = data;
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
61 AVFrame *const p = &s->picture;
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
62 uint8_t *ptr;
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
63
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
64 int magic_num, offset, endian;
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
65 int x, y;
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
66 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
67
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
68 unsigned int rgbBuffer;
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
69
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
70 magic_num = AV_RB32(buf);
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
71 buf += 4;
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
72
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
73 /* Check if the files "magic number" is "SDPX" which means it uses
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
74 * big-endian or XPDS which is for little-endian files */
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
75 if (magic_num == AV_RL32("SDPX")) {
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
76 endian = 0;
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
77 } else if (magic_num == AV_RB32("SDPX")) {
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
78 endian = 1;
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
79 } else {
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
80 av_log(avctx, AV_LOG_ERROR, "DPX marker not found\n");
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
81 return -1;
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
82 }
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
83
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
84 offset = read32(&buf, endian);
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
85 // Need to end in 0x304 offset from start of file
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
86 buf = avpkt->data + 0x304;
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
87 w = read32(&buf, endian);
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
88 h = read32(&buf, endian);
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
89
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
90 // Need to end in 0x320 to read the descriptor
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
91 buf += 20;
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
92 descriptor = buf[0];
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
93
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
94 // Need to end in 0x323 to read the bits per color
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
95 buf += 3;
10691
d54e52670962 Set bits_per_raw_sample appropriately in dpx decoder.
reimar
parents: 9839
diff changeset
96 avctx->bits_per_raw_sample =
9839
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
97 bits_per_color = buf[0];
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
98
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
99 switch (descriptor) {
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
100 case 51: // RGBA
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
101 elements = 4;
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
102 break;
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
103 case 50: // RGB
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
104 elements = 3;
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
105 break;
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
106 default:
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
107 av_log(avctx, AV_LOG_ERROR, "Unsupported descriptor %d\n", descriptor);
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
108 return -1;
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
109 }
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
110
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
111 switch (bits_per_color) {
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
112 case 8:
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
113 if (elements == 4) {
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
114 avctx->pix_fmt = PIX_FMT_RGBA;
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
115 } else {
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
116 avctx->pix_fmt = PIX_FMT_RGB24;
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
117 }
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
118 source_packet_size = elements;
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
119 target_packet_size = elements;
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
120 break;
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
121 case 10:
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
122 avctx->pix_fmt = PIX_FMT_RGB48;
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
123 target_packet_size = 6;
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
124 source_packet_size = elements * 2;
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
125 break;
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
126 case 12:
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
127 case 16:
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
128 if (endian) {
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
129 avctx->pix_fmt = PIX_FMT_RGB48BE;
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
130 } else {
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
131 avctx->pix_fmt = PIX_FMT_RGB48LE;
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
132 }
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
133 target_packet_size = 6;
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
134 source_packet_size = elements * 2;
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
135 break;
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
136 default:
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
137 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
138 return -1;
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
139 }
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
140
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
141 if (s->picture.data[0])
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
142 avctx->release_buffer(avctx, &s->picture);
12462
ffb3668ff7af Use new imgutils.h API names, fix deprecation warnings.
stefano
parents: 12372
diff changeset
143 if (av_image_check_size(w, h, 0, avctx))
9839
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
144 return -1;
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
145 if (w != avctx->width || h != avctx->height)
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
146 avcodec_set_dimensions(avctx, w, h);
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
147 if (avctx->get_buffer(avctx, p) < 0) {
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
148 av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
149 return -1;
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
150 }
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
151
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
152 // Move pointer to offset from start of file
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
153 buf = avpkt->data + offset;
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
154
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
155 ptr = p->data[0];
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
156 stride = p->linesize[0];
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
157
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
158 switch (bits_per_color) {
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
159 case 10:
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
160 for (x = 0; x < avctx->height; x++) {
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
161 uint16_t *dst = (uint16_t*)ptr;
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
162 for (y = 0; y < avctx->width; y++) {
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
163 rgbBuffer = read32(&buf, endian);
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
164 // Read out the 10-bit colors and convert to 16-bit
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
165 *dst++ = make_16bit(rgbBuffer >> 16);
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
166 *dst++ = make_16bit(rgbBuffer >> 6);
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
167 *dst++ = make_16bit(rgbBuffer << 4);
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
168 }
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
169 ptr += stride;
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
170 }
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
171 break;
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
172 case 8:
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
173 case 12: // Treat 12-bit as 16-bit
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
174 case 16:
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
175 if (source_packet_size == target_packet_size) {
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
176 for (x = 0; x < avctx->height; x++) {
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
177 memcpy(ptr, buf, target_packet_size*avctx->width);
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
178 ptr += stride;
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
179 buf += source_packet_size*avctx->width;
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
180 }
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
181 } else {
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
182 for (x = 0; x < avctx->height; x++) {
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
183 uint8_t *dst = ptr;
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
184 for (y = 0; y < avctx->width; y++) {
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
185 memcpy(dst, buf, target_packet_size);
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
186 dst += target_packet_size;
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
187 buf += source_packet_size;
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
188 }
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
189 ptr += stride;
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
190 }
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
191 }
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
192 break;
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
193 }
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
194
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
195 *picture = s->picture;
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
196 *data_size = sizeof(AVPicture);
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
197
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
198 return buf_size;
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
199 }
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
200
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
201 static av_cold int decode_init(AVCodecContext *avctx)
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
202 {
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
203 DPXContext *s = avctx->priv_data;
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
204 avcodec_get_frame_defaults(&s->picture);
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
205 avctx->coded_frame = &s->picture;
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
206 return 0;
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
207 }
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
208
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
209 static av_cold int decode_end(AVCodecContext *avctx)
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
210 {
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
211 DPXContext *s = avctx->priv_data;
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
212 if (s->picture.data[0])
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
213 avctx->release_buffer(avctx, &s->picture);
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
214
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
215 return 0;
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
216 }
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
217
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
218 AVCodec dpx_decoder = {
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
219 "dpx",
11560
8a4984c5cacc Define AVMediaType enum, and use it instead of enum CodecType, which
stefano
parents: 10691
diff changeset
220 AVMEDIA_TYPE_VIDEO,
9839
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
221 CODEC_ID_DPX,
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
222 sizeof(DPXContext),
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
223 decode_init,
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
224 NULL,
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
225 decode_end,
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
226 decode_frame,
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
227 0,
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
228 NULL,
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
229 .long_name = NULL_IF_CONFIG_SMALL("DPX image"),
ee32274eb802 DPX (Digital Picture Exchange) image decoder
diego
parents:
diff changeset
230 };