annotate cyuv.c @ 9774:69395e6a4d03 libavcodec

Change maskbit variable to contain (1 << maskbit)
author reimar
date Sun, 31 May 2009 10:58:20 +0000
parents 54bc8a2727b0
children 5da84f0d0a55
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 /*
5214
470601203f44 Group all copyright and author notices together.
diego
parents: 4962
diff changeset
2 * Creative YUV (CYUV) Video Decoder
470601203f44 Group all copyright and author notices together.
diego
parents: 4962
diff changeset
3 * by Mike Melanson (melanson@pcisys.net)
470601203f44 Group all copyright and author notices together.
diego
parents: 4962
diff changeset
4 * based on "Creative YUV (CYUV) stream format for AVI":
470601203f44 Group all copyright and author notices together.
diego
parents: 4962
diff changeset
5 * http://www.csse.monash.edu.au/~timf/videocodec/cyuv.txt
1054
f874e2122d45 Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff changeset
6 *
f874e2122d45 Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff changeset
7 * Copyright (C) 2003 the ffmpeg project
f874e2122d45 Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff changeset
8 *
3947
c8c591fe26f8 Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents: 3776
diff changeset
9 * This file is part of FFmpeg.
c8c591fe26f8 Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents: 3776
diff changeset
10 *
c8c591fe26f8 Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents: 3776
diff changeset
11 * 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
12 * 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
13 * 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
14 * 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
15 *
3947
c8c591fe26f8 Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents: 3776
diff changeset
16 * 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
17 * 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
18 * 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
19 * Lesser General Public License for more details.
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 * 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
22 * 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
23 * 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
24 */
f874e2122d45 Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff changeset
25
1106
1e39f273ecd6 per file doxy
michaelni
parents: 1064
diff changeset
26 /**
8718
e9d9d946f213 Use full internal pathname in doxygen @file directives.
diego
parents: 7979
diff changeset
27 * @file libavcodec/cyuv.c
1106
1e39f273ecd6 per file doxy
michaelni
parents: 1064
diff changeset
28 * Creative YUV (CYUV) Video Decoder.
1e39f273ecd6 per file doxy
michaelni
parents: 1064
diff changeset
29 */
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2826
diff changeset
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 "avcodec.h"
f874e2122d45 Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff changeset
37 #include "dsputil.h"
f874e2122d45 Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff changeset
38
f874e2122d45 Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff changeset
39
f874e2122d45 Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff changeset
40 typedef struct CyuvDecodeContext {
f874e2122d45 Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff changeset
41 AVCodecContext *avctx;
f874e2122d45 Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff changeset
42 int width, height;
f874e2122d45 Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff changeset
43 AVFrame frame;
f874e2122d45 Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff changeset
44 } CyuvDecodeContext;
f874e2122d45 Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff changeset
45
6517
48759bfbd073 Apply 'cold' attribute to init/uninit functions in libavcodec
zuxy
parents: 6450
diff changeset
46 static av_cold int cyuv_decode_init(AVCodecContext *avctx)
1054
f874e2122d45 Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff changeset
47 {
f874e2122d45 Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff changeset
48 CyuvDecodeContext *s = avctx->priv_data;
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 s->avctx = avctx;
f874e2122d45 Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff changeset
51 s->width = avctx->width;
2826
08cf92c2f7c0 tinfoil patch: accept no widths that are no multiples of 4
melanson
parents: 2028
diff changeset
52 /* 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
53 if (s->width & 0x3)
08cf92c2f7c0 tinfoil patch: accept no widths that are no multiples of 4
melanson
parents: 2028
diff changeset
54 return -1;
1054
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
f874e2122d45 Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff changeset
58 return 0;
f874e2122d45 Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff changeset
59 }
f874e2122d45 Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff changeset
60
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2826
diff changeset
61 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
62 void *data, int *data_size,
9355
54bc8a2727b0 Implement avcodec_decode_video2(), _audio3() and _subtitle2() which takes an
rbultje
parents: 8718
diff changeset
63 AVPacket *avpkt)
1054
f874e2122d45 Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff changeset
64 {
9355
54bc8a2727b0 Implement avcodec_decode_video2(), _audio3() and _subtitle2() which takes an
rbultje
parents: 8718
diff changeset
65 const uint8_t *buf = avpkt->data;
54bc8a2727b0 Implement avcodec_decode_video2(), _audio3() and _subtitle2() which takes an
rbultje
parents: 8718
diff changeset
66 int buf_size = avpkt->size;
1054
f874e2122d45 Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff changeset
67 CyuvDecodeContext *s=avctx->priv_data;
f874e2122d45 Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff changeset
68
f874e2122d45 Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff changeset
69 unsigned char *y_plane;
f874e2122d45 Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff changeset
70 unsigned char *u_plane;
f874e2122d45 Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff changeset
71 unsigned char *v_plane;
f874e2122d45 Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff changeset
72 int y_ptr;
f874e2122d45 Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff changeset
73 int u_ptr;
f874e2122d45 Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff changeset
74 int v_ptr;
f874e2122d45 Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff changeset
75
f874e2122d45 Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff changeset
76 /* prediction error tables (make it clear that they are signed values) */
6231
michael
parents: 5214
diff changeset
77 const signed char *y_table = (const signed char*)buf + 0;
michael
parents: 5214
diff changeset
78 const signed char *u_table = (const signed char*)buf + 16;
michael
parents: 5214
diff changeset
79 const signed char *v_table = (const signed char*)buf + 32;
1054
f874e2122d45 Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff changeset
80
f874e2122d45 Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff changeset
81 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
82 int stream_ptr;
f874e2122d45 Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff changeset
83 unsigned char cur_byte;
f874e2122d45 Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff changeset
84 int pixel_groups;
f874e2122d45 Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff changeset
85
f874e2122d45 Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff changeset
86 /* 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
87 * 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
88 * 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
89 * (3 * 16) + height * (width * 3 / 4) */
f874e2122d45 Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff changeset
90 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
91 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
92 buf_size,
f874e2122d45 Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff changeset
93 48 + s->height * (s->width * 3 / 4));
f874e2122d45 Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff changeset
94 return -1;
f874e2122d45 Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff changeset
95 }
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 /* 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
98 stream_ptr = 48;
f874e2122d45 Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff changeset
99
1228
d63e0185a90f release buffer cleanup
michaelni
parents: 1106
diff changeset
100 if(s->frame.data[0])
d63e0185a90f release buffer cleanup
michaelni
parents: 1106
diff changeset
101 avctx->release_buffer(avctx, &s->frame);
d63e0185a90f release buffer cleanup
michaelni
parents: 1106
diff changeset
102
2000
86220e37a31e Add buffer hints, enable DR1
rtognimp
parents: 1598
diff changeset
103 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
104 s->frame.reference = 0;
f874e2122d45 Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff changeset
105 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
106 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
107 return -1;
f874e2122d45 Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff changeset
108 }
f874e2122d45 Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff changeset
109
f874e2122d45 Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff changeset
110 y_plane = s->frame.data[0];
f874e2122d45 Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff changeset
111 u_plane = s->frame.data[1];
f874e2122d45 Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff changeset
112 v_plane = s->frame.data[2];
f874e2122d45 Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff changeset
113
f874e2122d45 Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff changeset
114 /* iterate through each line in the height */
f874e2122d45 Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff changeset
115 for (y_ptr = 0, u_ptr = 0, v_ptr = 0;
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2826
diff changeset
116 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
117 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
118 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
119 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
120
f874e2122d45 Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff changeset
121 /* reset predictors */
f874e2122d45 Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff changeset
122 cur_byte = buf[stream_ptr++];
f874e2122d45 Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff changeset
123 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
124 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
125
f874e2122d45 Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff changeset
126 cur_byte = buf[stream_ptr++];
f874e2122d45 Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff changeset
127 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
128 y_pred += y_table[cur_byte & 0x0F];
f874e2122d45 Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff changeset
129 y_plane[y_ptr++] = y_pred;
f874e2122d45 Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff changeset
130
f874e2122d45 Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff changeset
131 cur_byte = buf[stream_ptr++];
f874e2122d45 Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff changeset
132 y_pred += y_table[cur_byte & 0x0F];
f874e2122d45 Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff changeset
133 y_plane[y_ptr++] = y_pred;
f874e2122d45 Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff changeset
134 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
135 y_plane[y_ptr++] = y_pred;
f874e2122d45 Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff changeset
136
f874e2122d45 Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff changeset
137 /* 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
138 pixel_groups = s->width / 4 - 1;
f874e2122d45 Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff changeset
139 while (pixel_groups--) {
f874e2122d45 Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff changeset
140
f874e2122d45 Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff changeset
141 cur_byte = buf[stream_ptr++];
f874e2122d45 Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff changeset
142 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
143 u_plane[u_ptr++] = u_pred;
f874e2122d45 Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff changeset
144 y_pred += y_table[cur_byte & 0x0F];
f874e2122d45 Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff changeset
145 y_plane[y_ptr++] = y_pred;
f874e2122d45 Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff changeset
146
f874e2122d45 Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff changeset
147 cur_byte = buf[stream_ptr++];
f874e2122d45 Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff changeset
148 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
149 v_plane[v_ptr++] = v_pred;
f874e2122d45 Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff changeset
150 y_pred += y_table[cur_byte & 0x0F];
f874e2122d45 Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff changeset
151 y_plane[y_ptr++] = y_pred;
f874e2122d45 Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff changeset
152
f874e2122d45 Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff changeset
153 cur_byte = buf[stream_ptr++];
f874e2122d45 Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff changeset
154 y_pred += y_table[cur_byte & 0x0F];
f874e2122d45 Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff changeset
155 y_plane[y_ptr++] = y_pred;
f874e2122d45 Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff changeset
156 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
157 y_plane[y_ptr++] = y_pred;
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 }
f874e2122d45 Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff changeset
160 }
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 *data_size=sizeof(AVFrame);
f874e2122d45 Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff changeset
163 *(AVFrame*)data= s->frame;
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 return buf_size;
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
f874e2122d45 Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff changeset
168 AVCodec cyuv_decoder = {
f874e2122d45 Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff changeset
169 "cyuv",
f874e2122d45 Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff changeset
170 CODEC_TYPE_VIDEO,
f874e2122d45 Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff changeset
171 CODEC_ID_CYUV,
f874e2122d45 Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff changeset
172 sizeof(CyuvDecodeContext),
f874e2122d45 Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff changeset
173 cyuv_decode_init,
f874e2122d45 Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff changeset
174 NULL,
7979
5214daf6ce78 Remove useless cyuv_decode_end function
reimar
parents: 7040
diff changeset
175 NULL,
1054
f874e2122d45 Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff changeset
176 cyuv_decode_frame,
2000
86220e37a31e Add buffer hints, enable DR1
rtognimp
parents: 1598
diff changeset
177 CODEC_CAP_DR1,
6710
a4104482ceef Add long names to many AVCodec declarations.
diego
parents: 6517
diff changeset
178 NULL,
7040
e943e1409077 Make AVCodec long_names definition conditional depending on CONFIG_SMALL.
stefano
parents: 6710
diff changeset
179 .long_name = NULL_IF_CONFIG_SMALL("Creative YUV (CYUV)"),
1054
f874e2122d45 Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff changeset
180 };
f874e2122d45 Creative YUV (CYUV) decoder by (Mike Melanson <melanson at pcisys dot net>)
michaelni
parents:
diff changeset
181