Mercurial > libavcodec.hg
annotate cyuv.c @ 1134:27d225bd7176 libavcodec
* fixing cut&paste bug
author | kabi |
---|---|
date | Fri, 14 Mar 2003 07:24:25 +0000 |
parents | 1e39f273ecd6 |
children | d63e0185a90f |
rev | line source |
---|---|
1054
f874e2122d45
Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff
changeset
|
1 /* |
f874e2122d45
Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff
changeset
|
2 * |
f874e2122d45
Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff
changeset
|
3 * Copyright (C) 2003 the ffmpeg project |
f874e2122d45
Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff
changeset
|
4 * |
f874e2122d45
Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff
changeset
|
5 * This library is free software; you can redistribute it and/or |
f874e2122d45
Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff
changeset
|
6 * modify it under the terms of the GNU Lesser General Public |
f874e2122d45
Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff
changeset
|
7 * License as published by the Free Software Foundation; either |
f874e2122d45
Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff
changeset
|
8 * version 2 of the License, or (at your option) any later version. |
f874e2122d45
Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff
changeset
|
9 * |
f874e2122d45
Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff
changeset
|
10 * This library is distributed in the hope that it will be useful, |
f874e2122d45
Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff
changeset
|
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
f874e2122d45
Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff
changeset
|
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
f874e2122d45
Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff
changeset
|
13 * Lesser General Public License for more details. |
f874e2122d45
Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff
changeset
|
14 * |
f874e2122d45
Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff
changeset
|
15 * You should have received a copy of the GNU Lesser General Public |
f874e2122d45
Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff
changeset
|
16 * License along with this library; if not, write to the Free Software |
f874e2122d45
Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff
changeset
|
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
f874e2122d45
Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff
changeset
|
18 * |
f874e2122d45
Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff
changeset
|
19 * Creative YUV (CYUV) Video Decoder |
f874e2122d45
Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff
changeset
|
20 * by Mike Melanson (melanson@pcisys.net) |
f874e2122d45
Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff
changeset
|
21 * based on "Creative YUV (CYUV) stream format for AVI": |
f874e2122d45
Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff
changeset
|
22 * http://www.csse.monash.edu.au/~timf/videocodec/cyuv.txt |
f874e2122d45
Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff
changeset
|
23 * |
f874e2122d45
Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff
changeset
|
24 */ |
f874e2122d45
Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff
changeset
|
25 |
1106 | 26 /** |
27 * @file cyuv.c | |
28 * Creative YUV (CYUV) Video Decoder. | |
29 */ | |
30 | |
1054
f874e2122d45
Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff
changeset
|
31 #include <stdio.h> |
f874e2122d45
Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff
changeset
|
32 #include <stdlib.h> |
f874e2122d45
Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff
changeset
|
33 #include <string.h> |
f874e2122d45
Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff
changeset
|
34 #include <unistd.h> |
f874e2122d45
Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff
changeset
|
35 |
f874e2122d45
Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff
changeset
|
36 #include "common.h" |
f874e2122d45
Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff
changeset
|
37 #include "avcodec.h" |
f874e2122d45
Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff
changeset
|
38 #include "dsputil.h" |
f874e2122d45
Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff
changeset
|
39 #include "mpegvideo.h" |
f874e2122d45
Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff
changeset
|
40 #include "bswap.h" |
f874e2122d45
Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff
changeset
|
41 |
f874e2122d45
Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff
changeset
|
42 |
f874e2122d45
Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff
changeset
|
43 typedef struct CyuvDecodeContext { |
f874e2122d45
Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff
changeset
|
44 AVCodecContext *avctx; |
f874e2122d45
Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff
changeset
|
45 int width, height; |
f874e2122d45
Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff
changeset
|
46 AVFrame frame; |
f874e2122d45
Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff
changeset
|
47 } CyuvDecodeContext; |
f874e2122d45
Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff
changeset
|
48 |
f874e2122d45
Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff
changeset
|
49 static int cyuv_decode_init(AVCodecContext *avctx) |
f874e2122d45
Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff
changeset
|
50 { |
f874e2122d45
Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff
changeset
|
51 CyuvDecodeContext *s = avctx->priv_data; |
f874e2122d45
Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff
changeset
|
52 |
f874e2122d45
Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff
changeset
|
53 s->avctx = avctx; |
f874e2122d45
Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff
changeset
|
54 s->width = avctx->width; |
f874e2122d45
Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff
changeset
|
55 s->height = avctx->height; |
f874e2122d45
Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff
changeset
|
56 avctx->pix_fmt = PIX_FMT_YUV411P; |
f874e2122d45
Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff
changeset
|
57 avctx->has_b_frames = 0; |
f874e2122d45
Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff
changeset
|
58 |
f874e2122d45
Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff
changeset
|
59 return 0; |
f874e2122d45
Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff
changeset
|
60 } |
f874e2122d45
Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff
changeset
|
61 |
f874e2122d45
Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff
changeset
|
62 static int cyuv_decode_frame(AVCodecContext *avctx, |
f874e2122d45
Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff
changeset
|
63 void *data, int *data_size, |
1064 | 64 uint8_t *buf, int buf_size) |
1054
f874e2122d45
Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff
changeset
|
65 { |
f874e2122d45
Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff
changeset
|
66 CyuvDecodeContext *s=avctx->priv_data; |
f874e2122d45
Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff
changeset
|
67 |
f874e2122d45
Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff
changeset
|
68 unsigned char *y_plane; |
f874e2122d45
Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff
changeset
|
69 unsigned char *u_plane; |
f874e2122d45
Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff
changeset
|
70 unsigned char *v_plane; |
f874e2122d45
Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff
changeset
|
71 int y_ptr; |
f874e2122d45
Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff
changeset
|
72 int u_ptr; |
f874e2122d45
Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff
changeset
|
73 int v_ptr; |
f874e2122d45
Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff
changeset
|
74 |
f874e2122d45
Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff
changeset
|
75 /* prediction error tables (make it clear that they are signed values) */ |
f874e2122d45
Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff
changeset
|
76 signed char *y_table = buf + 0; |
f874e2122d45
Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff
changeset
|
77 signed char *u_table = buf + 16; |
f874e2122d45
Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff
changeset
|
78 signed char *v_table = buf + 32; |
f874e2122d45
Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff
changeset
|
79 |
f874e2122d45
Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff
changeset
|
80 unsigned char y_pred, u_pred, v_pred; |
f874e2122d45
Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff
changeset
|
81 int stream_ptr; |
f874e2122d45
Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff
changeset
|
82 unsigned char cur_byte; |
f874e2122d45
Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff
changeset
|
83 int pixel_groups; |
f874e2122d45
Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff
changeset
|
84 |
f874e2122d45
Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff
changeset
|
85 *data_size = 0; |
f874e2122d45
Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff
changeset
|
86 |
f874e2122d45
Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff
changeset
|
87 /* sanity check the buffer size: A buffer has 3x16-bytes tables |
f874e2122d45
Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff
changeset
|
88 * followed by (height) lines each with 3 bytes to represent groups |
f874e2122d45
Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff
changeset
|
89 * of 4 pixels. Thus, the total size of the buffer ought to be: |
f874e2122d45
Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff
changeset
|
90 * (3 * 16) + height * (width * 3 / 4) */ |
f874e2122d45
Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff
changeset
|
91 if (buf_size != 48 + s->height * (s->width * 3 / 4)) { |
f874e2122d45
Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff
changeset
|
92 printf ("ffmpeg: cyuv: got a buffer with %d bytes when %d were expected\n", |
f874e2122d45
Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff
changeset
|
93 buf_size, |
f874e2122d45
Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff
changeset
|
94 48 + s->height * (s->width * 3 / 4)); |
f874e2122d45
Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff
changeset
|
95 return -1; |
f874e2122d45
Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff
changeset
|
96 } |
f874e2122d45
Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff
changeset
|
97 |
f874e2122d45
Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff
changeset
|
98 /* pixel data starts 48 bytes in, after 3x16-byte tables */ |
f874e2122d45
Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff
changeset
|
99 stream_ptr = 48; |
f874e2122d45
Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff
changeset
|
100 |
f874e2122d45
Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff
changeset
|
101 s->frame.reference = 0; |
f874e2122d45
Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff
changeset
|
102 if(avctx->get_buffer(avctx, &s->frame) < 0) { |
f874e2122d45
Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff
changeset
|
103 fprintf(stderr, "get_buffer() failed\n"); |
f874e2122d45
Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff
changeset
|
104 return -1; |
f874e2122d45
Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff
changeset
|
105 } |
f874e2122d45
Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff
changeset
|
106 |
f874e2122d45
Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff
changeset
|
107 y_plane = s->frame.data[0]; |
f874e2122d45
Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff
changeset
|
108 u_plane = s->frame.data[1]; |
f874e2122d45
Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff
changeset
|
109 v_plane = s->frame.data[2]; |
f874e2122d45
Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff
changeset
|
110 |
f874e2122d45
Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff
changeset
|
111 /* iterate through each line in the height */ |
f874e2122d45
Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff
changeset
|
112 for (y_ptr = 0, u_ptr = 0, v_ptr = 0; |
f874e2122d45
Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff
changeset
|
113 y_ptr < (s->height * s->frame.linesize[0]); |
f874e2122d45
Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff
changeset
|
114 y_ptr += s->frame.linesize[0] - s->width, |
f874e2122d45
Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff
changeset
|
115 u_ptr += s->frame.linesize[1] - s->width / 4, |
f874e2122d45
Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff
changeset
|
116 v_ptr += s->frame.linesize[2] - s->width / 4) { |
f874e2122d45
Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff
changeset
|
117 |
f874e2122d45
Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff
changeset
|
118 /* reset predictors */ |
f874e2122d45
Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff
changeset
|
119 cur_byte = buf[stream_ptr++]; |
f874e2122d45
Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff
changeset
|
120 u_plane[u_ptr++] = u_pred = cur_byte & 0xF0; |
f874e2122d45
Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff
changeset
|
121 y_plane[y_ptr++] = y_pred = (cur_byte & 0x0F) << 4; |
f874e2122d45
Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff
changeset
|
122 |
f874e2122d45
Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff
changeset
|
123 cur_byte = buf[stream_ptr++]; |
f874e2122d45
Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff
changeset
|
124 v_plane[v_ptr++] = v_pred = cur_byte & 0xF0; |
f874e2122d45
Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff
changeset
|
125 y_pred += y_table[cur_byte & 0x0F]; |
f874e2122d45
Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff
changeset
|
126 y_plane[y_ptr++] = y_pred; |
f874e2122d45
Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff
changeset
|
127 |
f874e2122d45
Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff
changeset
|
128 cur_byte = buf[stream_ptr++]; |
f874e2122d45
Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff
changeset
|
129 y_pred += y_table[cur_byte & 0x0F]; |
f874e2122d45
Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff
changeset
|
130 y_plane[y_ptr++] = y_pred; |
f874e2122d45
Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff
changeset
|
131 y_pred += y_table[(cur_byte & 0xF0) >> 4]; |
f874e2122d45
Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff
changeset
|
132 y_plane[y_ptr++] = y_pred; |
f874e2122d45
Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff
changeset
|
133 |
f874e2122d45
Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff
changeset
|
134 /* iterate through the remaining pixel groups (4 pixels/group) */ |
f874e2122d45
Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff
changeset
|
135 pixel_groups = s->width / 4 - 1; |
f874e2122d45
Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff
changeset
|
136 while (pixel_groups--) { |
f874e2122d45
Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff
changeset
|
137 |
f874e2122d45
Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff
changeset
|
138 cur_byte = buf[stream_ptr++]; |
f874e2122d45
Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff
changeset
|
139 u_pred += u_table[(cur_byte & 0xF0) >> 4]; |
f874e2122d45
Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff
changeset
|
140 u_plane[u_ptr++] = u_pred; |
f874e2122d45
Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff
changeset
|
141 y_pred += y_table[cur_byte & 0x0F]; |
f874e2122d45
Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff
changeset
|
142 y_plane[y_ptr++] = y_pred; |
f874e2122d45
Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff
changeset
|
143 |
f874e2122d45
Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff
changeset
|
144 cur_byte = buf[stream_ptr++]; |
f874e2122d45
Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff
changeset
|
145 v_pred += v_table[(cur_byte & 0xF0) >> 4]; |
f874e2122d45
Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff
changeset
|
146 v_plane[v_ptr++] = v_pred; |
f874e2122d45
Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff
changeset
|
147 y_pred += y_table[cur_byte & 0x0F]; |
f874e2122d45
Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff
changeset
|
148 y_plane[y_ptr++] = y_pred; |
f874e2122d45
Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff
changeset
|
149 |
f874e2122d45
Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff
changeset
|
150 cur_byte = buf[stream_ptr++]; |
f874e2122d45
Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff
changeset
|
151 y_pred += y_table[cur_byte & 0x0F]; |
f874e2122d45
Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff
changeset
|
152 y_plane[y_ptr++] = y_pred; |
f874e2122d45
Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff
changeset
|
153 y_pred += y_table[(cur_byte & 0xF0) >> 4]; |
f874e2122d45
Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff
changeset
|
154 y_plane[y_ptr++] = y_pred; |
f874e2122d45
Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff
changeset
|
155 |
f874e2122d45
Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff
changeset
|
156 } |
f874e2122d45
Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff
changeset
|
157 } |
f874e2122d45
Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff
changeset
|
158 |
f874e2122d45
Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff
changeset
|
159 *data_size=sizeof(AVFrame); |
f874e2122d45
Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff
changeset
|
160 *(AVFrame*)data= s->frame; |
f874e2122d45
Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff
changeset
|
161 |
f874e2122d45
Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff
changeset
|
162 avctx->release_buffer(avctx, &s->frame); |
f874e2122d45
Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff
changeset
|
163 |
f874e2122d45
Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff
changeset
|
164 return buf_size; |
f874e2122d45
Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff
changeset
|
165 } |
f874e2122d45
Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff
changeset
|
166 |
f874e2122d45
Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff
changeset
|
167 static int cyuv_decode_end(AVCodecContext *avctx) |
f874e2122d45
Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff
changeset
|
168 { |
f874e2122d45
Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff
changeset
|
169 /* CyuvDecodeContext *s = avctx->priv_data;*/ |
f874e2122d45
Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff
changeset
|
170 |
f874e2122d45
Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff
changeset
|
171 return 0; |
f874e2122d45
Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff
changeset
|
172 } |
f874e2122d45
Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff
changeset
|
173 |
f874e2122d45
Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff
changeset
|
174 AVCodec cyuv_decoder = { |
f874e2122d45
Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff
changeset
|
175 "cyuv", |
f874e2122d45
Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff
changeset
|
176 CODEC_TYPE_VIDEO, |
f874e2122d45
Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff
changeset
|
177 CODEC_ID_CYUV, |
f874e2122d45
Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff
changeset
|
178 sizeof(CyuvDecodeContext), |
f874e2122d45
Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff
changeset
|
179 cyuv_decode_init, |
f874e2122d45
Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff
changeset
|
180 NULL, |
f874e2122d45
Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff
changeset
|
181 cyuv_decode_end, |
f874e2122d45
Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff
changeset
|
182 cyuv_decode_frame, |
f874e2122d45
Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff
changeset
|
183 0, |
f874e2122d45
Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff
changeset
|
184 NULL |
f874e2122d45
Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff
changeset
|
185 }; |
f874e2122d45
Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff
changeset
|
186 |