annotate cyuv.c @ 4074:861a55e86ef0 libavcodec

factorize update state out
author michael
date Tue, 24 Oct 2006 09:34:13 +0000
parents c8c591fe26f8
children 66ef3690d108
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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 *
3947
c8c591fe26f8 Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents: 3776
diff changeset
5 * This file is part of FFmpeg.
c8c591fe26f8 Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents: 3776
diff changeset
6 *
c8c591fe26f8 Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents: 3776
diff changeset
7 * FFmpeg is free software; you can redistribute it and/or
1054
f874e2122d45 Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff changeset
8 * 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
9 * License as published by the Free Software Foundation; either
3947
c8c591fe26f8 Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents: 3776
diff changeset
10 * version 2.1 of the License, or (at your option) any later version.
1054
f874e2122d45 Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff changeset
11 *
3947
c8c591fe26f8 Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents: 3776
diff changeset
12 * FFmpeg is distributed in the hope that it will be useful,
1054
f874e2122d45 Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff changeset
13 * 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
14 * 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
15 * Lesser General Public License for more details.
f874e2122d45 Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff changeset
16 *
f874e2122d45 Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff changeset
17 * You should have received a copy of the GNU Lesser General Public
3947
c8c591fe26f8 Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents: 3776
diff changeset
18 * License along with FFmpeg; if not, write to the Free Software
3036
0b546eab515d Update licensing information: The FSF changed postal address.
diego
parents: 2967
diff changeset
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
1054
f874e2122d45 Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff changeset
20 *
f874e2122d45 Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff changeset
21 * Creative YUV (CYUV) Video Decoder
f874e2122d45 Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff changeset
22 * by Mike Melanson (melanson@pcisys.net)
f874e2122d45 Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff changeset
23 * 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
24 * 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
25 *
f874e2122d45 Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff changeset
26 */
f874e2122d45 Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff changeset
27
1106
1e39f273ecd6 per file doxy
michaelni
parents: 1064
diff changeset
28 /**
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2826
diff changeset
29 * @file cyuv.c
1106
1e39f273ecd6 per file doxy
michaelni
parents: 1064
diff changeset
30 * Creative YUV (CYUV) Video Decoder.
1e39f273ecd6 per file doxy
michaelni
parents: 1064
diff changeset
31 */
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2826
diff changeset
32
1054
f874e2122d45 Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff changeset
33 #include <stdio.h>
f874e2122d45 Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff changeset
34 #include <stdlib.h>
f874e2122d45 Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff changeset
35 #include <string.h>
f874e2122d45 Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff changeset
36 #include <unistd.h>
f874e2122d45 Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff changeset
37
f874e2122d45 Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff changeset
38 #include "common.h"
f874e2122d45 Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff changeset
39 #include "avcodec.h"
f874e2122d45 Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff changeset
40 #include "dsputil.h"
f874e2122d45 Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff changeset
41 #include "mpegvideo.h"
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
f874e2122d45 Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff changeset
44 typedef struct CyuvDecodeContext {
f874e2122d45 Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff changeset
45 AVCodecContext *avctx;
f874e2122d45 Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff changeset
46 int width, height;
f874e2122d45 Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff changeset
47 AVFrame frame;
f874e2122d45 Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff changeset
48 } CyuvDecodeContext;
f874e2122d45 Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff changeset
49
f874e2122d45 Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff changeset
50 static int cyuv_decode_init(AVCodecContext *avctx)
f874e2122d45 Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff changeset
51 {
f874e2122d45 Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff changeset
52 CyuvDecodeContext *s = avctx->priv_data;
f874e2122d45 Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff changeset
53
f874e2122d45 Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff changeset
54 s->avctx = avctx;
f874e2122d45 Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff changeset
55 s->width = avctx->width;
2826
08cf92c2f7c0 tinfoil patch: accept no widths that are no multiples of 4
melanson
parents: 2028
diff changeset
56 /* width needs to be divisible by 4 for this codec to work */
08cf92c2f7c0 tinfoil patch: accept no widths that are no multiples of 4
melanson
parents: 2028
diff changeset
57 if (s->width & 0x3)
08cf92c2f7c0 tinfoil patch: accept no widths that are no multiples of 4
melanson
parents: 2028
diff changeset
58 return -1;
1054
f874e2122d45 Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff changeset
59 s->height = avctx->height;
f874e2122d45 Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff changeset
60 avctx->pix_fmt = PIX_FMT_YUV411P;
f874e2122d45 Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff changeset
61 avctx->has_b_frames = 0;
f874e2122d45 Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff changeset
62
f874e2122d45 Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff changeset
63 return 0;
f874e2122d45 Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff changeset
64 }
f874e2122d45 Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff changeset
65
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2826
diff changeset
66 static int cyuv_decode_frame(AVCodecContext *avctx,
1054
f874e2122d45 Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff changeset
67 void *data, int *data_size,
1064
b32afefe7d33 * UINTX -> uintx_t INTX -> intx_t
kabi
parents: 1054
diff changeset
68 uint8_t *buf, int buf_size)
1054
f874e2122d45 Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff changeset
69 {
f874e2122d45 Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff changeset
70 CyuvDecodeContext *s=avctx->priv_data;
f874e2122d45 Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff changeset
71
f874e2122d45 Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff changeset
72 unsigned char *y_plane;
f874e2122d45 Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff changeset
73 unsigned char *u_plane;
f874e2122d45 Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff changeset
74 unsigned char *v_plane;
f874e2122d45 Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff changeset
75 int y_ptr;
f874e2122d45 Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff changeset
76 int u_ptr;
f874e2122d45 Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff changeset
77 int v_ptr;
f874e2122d45 Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff changeset
78
f874e2122d45 Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff changeset
79 /* prediction error tables (make it clear that they are signed values) */
3776
1843a85123b7 fix some signedness warnings
mru
parents: 3036
diff changeset
80 signed char *y_table = (signed char*)buf + 0;
1843a85123b7 fix some signedness warnings
mru
parents: 3036
diff changeset
81 signed char *u_table = (signed char*)buf + 16;
1843a85123b7 fix some signedness warnings
mru
parents: 3036
diff changeset
82 signed char *v_table = (signed char*)buf + 32;
1054
f874e2122d45 Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff changeset
83
f874e2122d45 Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff changeset
84 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
85 int stream_ptr;
f874e2122d45 Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff changeset
86 unsigned char cur_byte;
f874e2122d45 Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff changeset
87 int pixel_groups;
f874e2122d45 Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff changeset
88
f874e2122d45 Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff changeset
89 /* 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
90 * 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
91 * 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
92 * (3 * 16) + height * (width * 3 / 4) */
f874e2122d45 Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff changeset
93 if (buf_size != 48 + s->height * (s->width * 3 / 4)) {
1598
932d306bf1dc av_log() patch by (Michel Bardiaux <mbardiaux at peaktime dot be>)
michael
parents: 1282
diff changeset
94 av_log(avctx, AV_LOG_ERROR, "ffmpeg: cyuv: got a buffer with %d bytes when %d were expected\n",
1054
f874e2122d45 Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff changeset
95 buf_size,
f874e2122d45 Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff changeset
96 48 + s->height * (s->width * 3 / 4));
f874e2122d45 Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff changeset
97 return -1;
f874e2122d45 Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff changeset
98 }
f874e2122d45 Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff changeset
99
f874e2122d45 Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff changeset
100 /* 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
101 stream_ptr = 48;
f874e2122d45 Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff changeset
102
1228
d63e0185a90f release buffer cleanup
michaelni
parents: 1106
diff changeset
103 if(s->frame.data[0])
d63e0185a90f release buffer cleanup
michaelni
parents: 1106
diff changeset
104 avctx->release_buffer(avctx, &s->frame);
d63e0185a90f release buffer cleanup
michaelni
parents: 1106
diff changeset
105
2000
86220e37a31e Add buffer hints, enable DR1
rtognimp
parents: 1598
diff changeset
106 s->frame.buffer_hints = FF_BUFFER_HINTS_VALID;
1054
f874e2122d45 Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff changeset
107 s->frame.reference = 0;
f874e2122d45 Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff changeset
108 if(avctx->get_buffer(avctx, &s->frame) < 0) {
1598
932d306bf1dc av_log() patch by (Michel Bardiaux <mbardiaux at peaktime dot be>)
michael
parents: 1282
diff changeset
109 av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
1054
f874e2122d45 Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff changeset
110 return -1;
f874e2122d45 Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff changeset
111 }
f874e2122d45 Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff changeset
112
f874e2122d45 Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff changeset
113 y_plane = s->frame.data[0];
f874e2122d45 Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff changeset
114 u_plane = s->frame.data[1];
f874e2122d45 Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff changeset
115 v_plane = s->frame.data[2];
f874e2122d45 Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff changeset
116
f874e2122d45 Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff changeset
117 /* iterate through each line in the height */
f874e2122d45 Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff changeset
118 for (y_ptr = 0, u_ptr = 0, v_ptr = 0;
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2826
diff changeset
119 y_ptr < (s->height * s->frame.linesize[0]);
1054
f874e2122d45 Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff changeset
120 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
121 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
122 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
123
f874e2122d45 Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff changeset
124 /* reset predictors */
f874e2122d45 Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff changeset
125 cur_byte = buf[stream_ptr++];
f874e2122d45 Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff changeset
126 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
127 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
128
f874e2122d45 Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff changeset
129 cur_byte = buf[stream_ptr++];
f874e2122d45 Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff changeset
130 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
131 y_pred += y_table[cur_byte & 0x0F];
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 cur_byte = buf[stream_ptr++];
f874e2122d45 Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff changeset
135 y_pred += y_table[cur_byte & 0x0F];
f874e2122d45 Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff changeset
136 y_plane[y_ptr++] = y_pred;
f874e2122d45 Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff changeset
137 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
138 y_plane[y_ptr++] = y_pred;
f874e2122d45 Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff changeset
139
f874e2122d45 Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff changeset
140 /* 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
141 pixel_groups = s->width / 4 - 1;
f874e2122d45 Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff changeset
142 while (pixel_groups--) {
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 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
146 u_plane[u_ptr++] = u_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 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
152 v_plane[v_ptr++] = v_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 & 0x0F];
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 cur_byte = buf[stream_ptr++];
f874e2122d45 Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff changeset
157 y_pred += y_table[cur_byte & 0x0F];
f874e2122d45 Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff changeset
158 y_plane[y_ptr++] = y_pred;
f874e2122d45 Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff changeset
159 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
160 y_plane[y_ptr++] = y_pred;
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 }
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
f874e2122d45 Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff changeset
165 *data_size=sizeof(AVFrame);
f874e2122d45 Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff changeset
166 *(AVFrame*)data= s->frame;
f874e2122d45 Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff changeset
167
f874e2122d45 Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff changeset
168 return buf_size;
f874e2122d45 Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff changeset
169 }
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 static int cyuv_decode_end(AVCodecContext *avctx)
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 /* CyuvDecodeContext *s = avctx->priv_data;*/
f874e2122d45 Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff changeset
174
f874e2122d45 Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff changeset
175 return 0;
f874e2122d45 Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff changeset
176 }
f874e2122d45 Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff changeset
177
f874e2122d45 Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff changeset
178 AVCodec cyuv_decoder = {
f874e2122d45 Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff changeset
179 "cyuv",
f874e2122d45 Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff changeset
180 CODEC_TYPE_VIDEO,
f874e2122d45 Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff changeset
181 CODEC_ID_CYUV,
f874e2122d45 Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff changeset
182 sizeof(CyuvDecodeContext),
f874e2122d45 Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff changeset
183 cyuv_decode_init,
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 cyuv_decode_end,
f874e2122d45 Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff changeset
186 cyuv_decode_frame,
2000
86220e37a31e Add buffer hints, enable DR1
rtognimp
parents: 1598
diff changeset
187 CODEC_CAP_DR1,
1054
f874e2122d45 Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff changeset
188 NULL
f874e2122d45 Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff changeset
189 };
f874e2122d45 Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff changeset
190