annotate ulti.c @ 11903:f3e007b379e5 libavcodec

aacdec: Factorize if (elem_type < TYPE_DSE).
author alexc
date Mon, 21 Jun 2010 04:07:19 +0000
parents 7dd2a45249a9
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2234
dff53892ff8a IBM Ultimotion video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
1 /*
2779
alex
parents: 2234
diff changeset
2 * IBM Ultimotion Video Decoder
2234
dff53892ff8a IBM Ultimotion video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
3 * Copyright (C) 2004 Konstantin Shishkov
dff53892ff8a IBM Ultimotion video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
4 *
3947
c8c591fe26f8 Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents: 3036
diff changeset
5 * This file is part of FFmpeg.
c8c591fe26f8 Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents: 3036
diff changeset
6 *
c8c591fe26f8 Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents: 3036
diff changeset
7 * FFmpeg is free software; you can redistribute it and/or
2234
dff53892ff8a IBM Ultimotion video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
8 * modify it under the terms of the GNU Lesser General Public
dff53892ff8a IBM Ultimotion video decoder, courtesy of Konstantin Shishkov
melanson
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: 3036
diff changeset
10 * version 2.1 of the License, or (at your option) any later version.
2234
dff53892ff8a IBM Ultimotion video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
11 *
3947
c8c591fe26f8 Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents: 3036
diff changeset
12 * FFmpeg is distributed in the hope that it will be useful,
2234
dff53892ff8a IBM Ultimotion video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
dff53892ff8a IBM Ultimotion video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
dff53892ff8a IBM Ultimotion video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
15 * Lesser General Public License for more details.
dff53892ff8a IBM Ultimotion video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
16 *
dff53892ff8a IBM Ultimotion video decoder, courtesy of Konstantin Shishkov
melanson
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: 3036
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: 2979
diff changeset
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
2234
dff53892ff8a IBM Ultimotion video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
20 */
dff53892ff8a IBM Ultimotion video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
21
dff53892ff8a IBM Ultimotion video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
22 /**
11644
7dd2a45249a9 Remove explicit filename from Doxygen @file commands.
diego
parents: 11560
diff changeset
23 * @file
2234
dff53892ff8a IBM Ultimotion video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
24 * IBM Ultimotion Video Decoder.
dff53892ff8a IBM Ultimotion video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
25 */
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2834
diff changeset
26
2234
dff53892ff8a IBM Ultimotion video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
27 #include <stdio.h>
dff53892ff8a IBM Ultimotion video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
28 #include <stdlib.h>
dff53892ff8a IBM Ultimotion video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
29 #include <string.h>
dff53892ff8a IBM Ultimotion video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
30
dff53892ff8a IBM Ultimotion video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
31 #include "avcodec.h"
5089
bff60ecc02f9 Use AV_xx throughout libavcodec
ramiro
parents: 4962
diff changeset
32 #include "bytestream.h"
2234
dff53892ff8a IBM Ultimotion video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
33
dff53892ff8a IBM Ultimotion video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
34 #include "ulti_cb.h"
dff53892ff8a IBM Ultimotion video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
35
dff53892ff8a IBM Ultimotion video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
36 typedef struct UltimotionDecodeContext {
dff53892ff8a IBM Ultimotion video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
37 AVCodecContext *avctx;
dff53892ff8a IBM Ultimotion video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
38 int width, height, blocks;
dff53892ff8a IBM Ultimotion video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
39 AVFrame frame;
2834
fd5d7c732c6b kill a bunch of compiler warnings
mru
parents: 2779
diff changeset
40 const uint8_t *ulti_codebook;
2234
dff53892ff8a IBM Ultimotion video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
41 } UltimotionDecodeContext;
dff53892ff8a IBM Ultimotion video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
42
6517
48759bfbd073 Apply 'cold' attribute to init/uninit functions in libavcodec
zuxy
parents: 6218
diff changeset
43 static av_cold int ulti_decode_init(AVCodecContext *avctx)
2234
dff53892ff8a IBM Ultimotion video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
44 {
dff53892ff8a IBM Ultimotion video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
45 UltimotionDecodeContext *s = avctx->priv_data;
dff53892ff8a IBM Ultimotion video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
46
dff53892ff8a IBM Ultimotion video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
47 s->avctx = avctx;
dff53892ff8a IBM Ultimotion video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
48 s->width = avctx->width;
dff53892ff8a IBM Ultimotion video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
49 s->height = avctx->height;
dff53892ff8a IBM Ultimotion video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
50 s->blocks = (s->width / 8) * (s->height / 8);
dff53892ff8a IBM Ultimotion video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
51 avctx->pix_fmt = PIX_FMT_YUV410P;
dff53892ff8a IBM Ultimotion video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
52 avctx->coded_frame = (AVFrame*) &s->frame;
dff53892ff8a IBM Ultimotion video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
53 s->ulti_codebook = ulti_codebook;
dff53892ff8a IBM Ultimotion video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
54
dff53892ff8a IBM Ultimotion video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
55 return 0;
dff53892ff8a IBM Ultimotion video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
56 }
dff53892ff8a IBM Ultimotion video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
57
10399
136334ad62b3 Release frame after decoding is done
kostya
parents: 10132
diff changeset
58 static av_cold int ulti_decode_end(AVCodecContext *avctx){
136334ad62b3 Release frame after decoding is done
kostya
parents: 10132
diff changeset
59 UltimotionDecodeContext *s = avctx->priv_data;
136334ad62b3 Release frame after decoding is done
kostya
parents: 10132
diff changeset
60 AVFrame *pic = &s->frame;
136334ad62b3 Release frame after decoding is done
kostya
parents: 10132
diff changeset
61
136334ad62b3 Release frame after decoding is done
kostya
parents: 10132
diff changeset
62 if (pic->data[0])
136334ad62b3 Release frame after decoding is done
kostya
parents: 10132
diff changeset
63 avctx->release_buffer(avctx, pic);
136334ad62b3 Release frame after decoding is done
kostya
parents: 10132
diff changeset
64
136334ad62b3 Release frame after decoding is done
kostya
parents: 10132
diff changeset
65 return 0;
136334ad62b3 Release frame after decoding is done
kostya
parents: 10132
diff changeset
66 }
136334ad62b3 Release frame after decoding is done
kostya
parents: 10132
diff changeset
67
7129
322023e630a6 mark read-only data as const
stefang
parents: 7040
diff changeset
68 static const int block_coords[8] = // 4x4 block coords in 8x8 superblock
2234
dff53892ff8a IBM Ultimotion video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
69 { 0, 0, 0, 4, 4, 4, 4, 0};
dff53892ff8a IBM Ultimotion video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
70
7129
322023e630a6 mark read-only data as const
stefang
parents: 7040
diff changeset
71 static const int angle_by_index[4] = { 0, 2, 6, 12};
2234
dff53892ff8a IBM Ultimotion video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
72
dff53892ff8a IBM Ultimotion video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
73 /* Lookup tables for luma and chroma - used by ulti_convert_yuv() */
7129
322023e630a6 mark read-only data as const
stefang
parents: 7040
diff changeset
74 static const uint8_t ulti_lumas[64] =
2234
dff53892ff8a IBM Ultimotion video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
75 { 0x10, 0x13, 0x17, 0x1A, 0x1E, 0x21, 0x25, 0x28,
dff53892ff8a IBM Ultimotion video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
76 0x2C, 0x2F, 0x33, 0x36, 0x3A, 0x3D, 0x41, 0x44,
dff53892ff8a IBM Ultimotion video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
77 0x48, 0x4B, 0x4F, 0x52, 0x56, 0x59, 0x5C, 0x60,
dff53892ff8a IBM Ultimotion video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
78 0x63, 0x67, 0x6A, 0x6E, 0x71, 0x75, 0x78, 0x7C,
dff53892ff8a IBM Ultimotion video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
79 0x7F, 0x83, 0x86, 0x8A, 0x8D, 0x91, 0x94, 0x98,
dff53892ff8a IBM Ultimotion video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
80 0x9B, 0x9F, 0xA2, 0xA5, 0xA9, 0xAC, 0xB0, 0xB3,
dff53892ff8a IBM Ultimotion video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
81 0xB7, 0xBA, 0xBE, 0xC1, 0xC5, 0xC8, 0xCC, 0xCF,
dff53892ff8a IBM Ultimotion video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
82 0xD3, 0xD6, 0xDA, 0xDD, 0xE1, 0xE4, 0xE8, 0xEB};
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2834
diff changeset
83
7129
322023e630a6 mark read-only data as const
stefang
parents: 7040
diff changeset
84 static const uint8_t ulti_chromas[16] =
2234
dff53892ff8a IBM Ultimotion video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
85 { 0x60, 0x67, 0x6D, 0x73, 0x7A, 0x80, 0x86, 0x8D,
dff53892ff8a IBM Ultimotion video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
86 0x93, 0x99, 0xA0, 0xA6, 0xAC, 0xB3, 0xB9, 0xC0};
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2834
diff changeset
87
2234
dff53892ff8a IBM Ultimotion video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
88 /* convert Ultimotion YUV block (sixteen 6-bit Y samples and
dff53892ff8a IBM Ultimotion video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
89 two 4-bit chroma samples) into standard YUV and put it into frame */
dff53892ff8a IBM Ultimotion video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
90 static void ulti_convert_yuv(AVFrame *frame, int x, int y,
2979
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
91 uint8_t *luma,int chroma)
2234
dff53892ff8a IBM Ultimotion video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
92 {
dff53892ff8a IBM Ultimotion video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
93 uint8_t *y_plane, *cr_plane, *cb_plane;
dff53892ff8a IBM Ultimotion video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
94 int i;
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2834
diff changeset
95
2234
dff53892ff8a IBM Ultimotion video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
96 y_plane = frame->data[0] + x + y * frame->linesize[0];
dff53892ff8a IBM Ultimotion video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
97 cr_plane = frame->data[1] + (x / 4) + (y / 4) * frame->linesize[1];
dff53892ff8a IBM Ultimotion video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
98 cb_plane = frame->data[2] + (x / 4) + (y / 4) * frame->linesize[2];
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2834
diff changeset
99
2234
dff53892ff8a IBM Ultimotion video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
100 cr_plane[0] = ulti_chromas[chroma >> 4];
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2834
diff changeset
101
2234
dff53892ff8a IBM Ultimotion video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
102 cb_plane[0] = ulti_chromas[chroma & 0xF];
dff53892ff8a IBM Ultimotion video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
103
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2834
diff changeset
104
2234
dff53892ff8a IBM Ultimotion video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
105 for(i = 0; i < 16; i++){
2979
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
106 y_plane[i & 3] = ulti_lumas[luma[i]];
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
107 if((i & 3) == 3) { //next row
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
108 y_plane += frame->linesize[0];
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
109 }
2234
dff53892ff8a IBM Ultimotion video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
110 }
dff53892ff8a IBM Ultimotion video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
111 }
dff53892ff8a IBM Ultimotion video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
112
dff53892ff8a IBM Ultimotion video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
113 /* generate block like in MS Video1 */
dff53892ff8a IBM Ultimotion video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
114 static void ulti_pattern(AVFrame *frame, int x, int y,
2979
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
115 int f0, int f1, int Y0, int Y1, int chroma)
2234
dff53892ff8a IBM Ultimotion video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
116 {
dff53892ff8a IBM Ultimotion video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
117 uint8_t Luma[16];
dff53892ff8a IBM Ultimotion video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
118 int mask, i;
dff53892ff8a IBM Ultimotion video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
119 for(mask = 0x80, i = 0; mask; mask >>= 1, i++) {
2979
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
120 if(f0 & mask)
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
121 Luma[i] = Y1;
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
122 else
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
123 Luma[i] = Y0;
2234
dff53892ff8a IBM Ultimotion video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
124 }
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2834
diff changeset
125
2234
dff53892ff8a IBM Ultimotion video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
126 for(mask = 0x80, i = 8; mask; mask >>= 1, i++) {
2979
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
127 if(f1 & mask)
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
128 Luma[i] = Y1;
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
129 else
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
130 Luma[i] = Y0;
2234
dff53892ff8a IBM Ultimotion video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
131 }
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2834
diff changeset
132
2234
dff53892ff8a IBM Ultimotion video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
133 ulti_convert_yuv(frame, x, y, Luma, chroma);
dff53892ff8a IBM Ultimotion video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
134 }
dff53892ff8a IBM Ultimotion video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
135
dff53892ff8a IBM Ultimotion video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
136 /* fill block with some gradient */
dff53892ff8a IBM Ultimotion video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
137 static void ulti_grad(AVFrame *frame, int x, int y, uint8_t *Y, int chroma, int angle)
dff53892ff8a IBM Ultimotion video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
138 {
dff53892ff8a IBM Ultimotion video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
139 uint8_t Luma[16];
dff53892ff8a IBM Ultimotion video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
140 if(angle & 8) { //reverse order
2979
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
141 int t;
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
142 angle &= 0x7;
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
143 t = Y[0];
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
144 Y[0] = Y[3];
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
145 Y[3] = t;
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
146 t = Y[1];
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
147 Y[1] = Y[2];
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
148 Y[2] = t;
2234
dff53892ff8a IBM Ultimotion video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
149 }
dff53892ff8a IBM Ultimotion video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
150 switch(angle){
dff53892ff8a IBM Ultimotion video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
151 case 0:
2979
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
152 Luma[0] = Y[0]; Luma[1] = Y[1]; Luma[2] = Y[2]; Luma[3] = Y[3];
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
153 Luma[4] = Y[0]; Luma[5] = Y[1]; Luma[6] = Y[2]; Luma[7] = Y[3];
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
154 Luma[8] = Y[0]; Luma[9] = Y[1]; Luma[10] = Y[2]; Luma[11] = Y[3];
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
155 Luma[12] = Y[0]; Luma[13] = Y[1]; Luma[14] = Y[2]; Luma[15] = Y[3];
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
156 break;
2234
dff53892ff8a IBM Ultimotion video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
157 case 1:
2979
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
158 Luma[0] = Y[1]; Luma[1] = Y[2]; Luma[2] = Y[3]; Luma[3] = Y[3];
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
159 Luma[4] = Y[0]; Luma[5] = Y[1]; Luma[6] = Y[2]; Luma[7] = Y[3];
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
160 Luma[8] = Y[0]; Luma[9] = Y[1]; Luma[10] = Y[2]; Luma[11] = Y[3];
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
161 Luma[12] = Y[0]; Luma[13] = Y[0]; Luma[14] = Y[1]; Luma[15] = Y[2];
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
162 break;
2234
dff53892ff8a IBM Ultimotion video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
163 case 2:
2979
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
164 Luma[0] = Y[1]; Luma[1] = Y[2]; Luma[2] = Y[3]; Luma[3] = Y[3];
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
165 Luma[4] = Y[1]; Luma[5] = Y[2]; Luma[6] = Y[2]; Luma[7] = Y[3];
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
166 Luma[8] = Y[0]; Luma[9] = Y[1]; Luma[10] = Y[1]; Luma[11] = Y[2];
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
167 Luma[12] = Y[0]; Luma[13] = Y[0]; Luma[14] = Y[1]; Luma[15] = Y[2];
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
168 break;
2234
dff53892ff8a IBM Ultimotion video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
169 case 3:
2979
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
170 Luma[0] = Y[2]; Luma[1] = Y[3]; Luma[2] = Y[3]; Luma[3] = Y[3];
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
171 Luma[4] = Y[1]; Luma[5] = Y[2]; Luma[6] = Y[2]; Luma[7] = Y[3];
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
172 Luma[8] = Y[0]; Luma[9] = Y[1]; Luma[10] = Y[1]; Luma[11] = Y[2];
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
173 Luma[12] = Y[0]; Luma[13] = Y[0]; Luma[14] = Y[0]; Luma[15] = Y[1];
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
174 break;
2234
dff53892ff8a IBM Ultimotion video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
175 case 4:
2979
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
176 Luma[0] = Y[3]; Luma[1] = Y[3]; Luma[2] = Y[3]; Luma[3] = Y[3];
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
177 Luma[4] = Y[2]; Luma[5] = Y[2]; Luma[6] = Y[2]; Luma[7] = Y[2];
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
178 Luma[8] = Y[1]; Luma[9] = Y[1]; Luma[10] = Y[1]; Luma[11] = Y[1];
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
179 Luma[12] = Y[0]; Luma[13] = Y[0]; Luma[14] = Y[0]; Luma[15] = Y[0];
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
180 break;
2234
dff53892ff8a IBM Ultimotion video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
181 case 5:
2979
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
182 Luma[0] = Y[3]; Luma[1] = Y[3]; Luma[2] = Y[3]; Luma[3] = Y[2];
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
183 Luma[4] = Y[3]; Luma[5] = Y[2]; Luma[6] = Y[2]; Luma[7] = Y[1];
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
184 Luma[8] = Y[2]; Luma[9] = Y[1]; Luma[10] = Y[1]; Luma[11] = Y[0];
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
185 Luma[12] = Y[1]; Luma[13] = Y[0]; Luma[14] = Y[0]; Luma[15] = Y[0];
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
186 break;
2234
dff53892ff8a IBM Ultimotion video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
187 case 6:
2979
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
188 Luma[0] = Y[3]; Luma[1] = Y[3]; Luma[2] = Y[2]; Luma[3] = Y[2];
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
189 Luma[4] = Y[3]; Luma[5] = Y[2]; Luma[6] = Y[1]; Luma[7] = Y[1];
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
190 Luma[8] = Y[2]; Luma[9] = Y[2]; Luma[10] = Y[1]; Luma[11] = Y[0];
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
191 Luma[12] = Y[1]; Luma[13] = Y[1]; Luma[14] = Y[0]; Luma[15] = Y[0];
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
192 break;
2234
dff53892ff8a IBM Ultimotion video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
193 case 7:
2979
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
194 Luma[0] = Y[3]; Luma[1] = Y[3]; Luma[2] = Y[2]; Luma[3] = Y[1];
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
195 Luma[4] = Y[3]; Luma[5] = Y[2]; Luma[6] = Y[1]; Luma[7] = Y[0];
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
196 Luma[8] = Y[3]; Luma[9] = Y[2]; Luma[10] = Y[1]; Luma[11] = Y[0];
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
197 Luma[12] = Y[2]; Luma[13] = Y[1]; Luma[14] = Y[0]; Luma[15] = Y[0];
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
198 break;
2234
dff53892ff8a IBM Ultimotion video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
199 default:
2979
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
200 Luma[0] = Y[0]; Luma[1] = Y[0]; Luma[2] = Y[1]; Luma[3] = Y[1];
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
201 Luma[4] = Y[0]; Luma[5] = Y[0]; Luma[6] = Y[1]; Luma[7] = Y[1];
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
202 Luma[8] = Y[2]; Luma[9] = Y[2]; Luma[10] = Y[3]; Luma[11] = Y[3];
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
203 Luma[12] = Y[2]; Luma[13] = Y[2]; Luma[14] = Y[3]; Luma[15] = Y[3];
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
204 break;
2234
dff53892ff8a IBM Ultimotion video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
205 }
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2834
diff changeset
206
2234
dff53892ff8a IBM Ultimotion video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
207 ulti_convert_yuv(frame, x, y, Luma, chroma);
dff53892ff8a IBM Ultimotion video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
208 }
dff53892ff8a IBM Ultimotion video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
209
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2834
diff changeset
210 static int ulti_decode_frame(AVCodecContext *avctx,
2234
dff53892ff8a IBM Ultimotion video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
211 void *data, int *data_size,
9355
54bc8a2727b0 Implement avcodec_decode_video2(), _audio3() and _subtitle2() which takes an
rbultje
parents: 8718
diff changeset
212 AVPacket *avpkt)
2234
dff53892ff8a IBM Ultimotion video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
213 {
9355
54bc8a2727b0 Implement avcodec_decode_video2(), _audio3() and _subtitle2() which takes an
rbultje
parents: 8718
diff changeset
214 const uint8_t *buf = avpkt->data;
54bc8a2727b0 Implement avcodec_decode_video2(), _audio3() and _subtitle2() which takes an
rbultje
parents: 8718
diff changeset
215 int buf_size = avpkt->size;
2234
dff53892ff8a IBM Ultimotion video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
216 UltimotionDecodeContext *s=avctx->priv_data;
dff53892ff8a IBM Ultimotion video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
217 int modifier = 0;
dff53892ff8a IBM Ultimotion video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
218 int uniq = 0;
dff53892ff8a IBM Ultimotion video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
219 int mode = 0;
dff53892ff8a IBM Ultimotion video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
220 int blocks = 0;
dff53892ff8a IBM Ultimotion video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
221 int done = 0;
dff53892ff8a IBM Ultimotion video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
222 int x = 0, y = 0;
dff53892ff8a IBM Ultimotion video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
223 int i;
dff53892ff8a IBM Ultimotion video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
224 int skip;
dff53892ff8a IBM Ultimotion video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
225 int tmp;
dff53892ff8a IBM Ultimotion video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
226
dff53892ff8a IBM Ultimotion video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
227 if(s->frame.data[0])
dff53892ff8a IBM Ultimotion video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
228 avctx->release_buffer(avctx, &s->frame);
dff53892ff8a IBM Ultimotion video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
229
dff53892ff8a IBM Ultimotion video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
230 s->frame.reference = 1;
dff53892ff8a IBM Ultimotion video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
231 s->frame.buffer_hints = FF_BUFFER_HINTS_VALID | FF_BUFFER_HINTS_PRESERVE | FF_BUFFER_HINTS_REUSABLE;
dff53892ff8a IBM Ultimotion video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
232 if(avctx->get_buffer(avctx, &s->frame) < 0) {
dff53892ff8a IBM Ultimotion video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
233 av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
dff53892ff8a IBM Ultimotion video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
234 return -1;
dff53892ff8a IBM Ultimotion video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
235 }
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2834
diff changeset
236
2234
dff53892ff8a IBM Ultimotion video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
237 while(!done) {
2979
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
238 int idx;
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
239 if(blocks >= s->blocks || y >= s->height)
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
240 break;//all blocks decoded
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2834
diff changeset
241
2979
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
242 idx = *buf++;
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
243 if((idx & 0xF8) == 0x70) {
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
244 switch(idx) {
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
245 case 0x70: //change modifier
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
246 modifier = *buf++;
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
247 if(modifier>1)
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
248 av_log(avctx, AV_LOG_INFO, "warning: modifier must be 0 or 1, got %i\n", modifier);
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
249 break;
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
250 case 0x71: // set uniq flag
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
251 uniq = 1;
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
252 break;
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
253 case 0x72: //toggle mode
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
254 mode = !mode;
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
255 break;
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
256 case 0x73: //end-of-frame
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
257 done = 1;
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
258 break;
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
259 case 0x74: //skip some blocks
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
260 skip = *buf++;
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
261 if ((blocks + skip) >= s->blocks)
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
262 break;
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
263 blocks += skip;
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
264 x += skip * 8;
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
265 while(x >= s->width) {
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
266 x -= s->width;
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
267 y += 8;
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
268 }
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
269 break;
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
270 default:
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
271 av_log(avctx, AV_LOG_INFO, "warning: unknown escape 0x%02X\n", idx);
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
272 }
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
273 } else { //handle one block
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
274 int code;
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
275 int cf;
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
276 int angle = 0;
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
277 uint8_t Y[4]; // luma samples of block
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
278 int tx = 0, ty = 0; //coords of subblock
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
279 int chroma = 0;
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
280 if (mode || uniq) {
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
281 uniq = 0;
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
282 cf = 1;
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
283 chroma = 0;
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
284 } else {
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
285 cf = 0;
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
286 if (idx)
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
287 chroma = *buf++;
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
288 }
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
289 for (i = 0; i < 4; i++) { // for every subblock
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
290 code = (idx >> (6 - i*2)) & 3; //extract 2 bits
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
291 if(!code) //skip subblock
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
292 continue;
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
293 if(cf)
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
294 chroma = *buf++;
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
295 tx = x + block_coords[i * 2];
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
296 ty = y + block_coords[(i * 2) + 1];
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
297 switch(code) {
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
298 case 1:
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
299 tmp = *buf++;
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2834
diff changeset
300
2979
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
301 angle = angle_by_index[(tmp >> 6) & 0x3];
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2834
diff changeset
302
2979
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
303 Y[0] = tmp & 0x3F;
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
304 Y[1] = Y[0];
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2834
diff changeset
305
2979
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
306 if (angle) {
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
307 Y[2] = Y[0]+1;
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
308 if (Y[2] > 0x3F)
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
309 Y[2] = 0x3F;
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
310 Y[3] = Y[2];
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
311 } else {
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
312 Y[2] = Y[0];
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
313 Y[3] = Y[0];
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
314 }
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
315 break;
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2834
diff changeset
316
2979
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
317 case 2:
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
318 if (modifier) { // unpack four luma samples
5089
bff60ecc02f9 Use AV_xx throughout libavcodec
ramiro
parents: 4962
diff changeset
319 tmp = bytestream_get_be24(&buf);
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2834
diff changeset
320
2979
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
321 Y[0] = (tmp >> 18) & 0x3F;
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
322 Y[1] = (tmp >> 12) & 0x3F;
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
323 Y[2] = (tmp >> 6) & 0x3F;
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
324 Y[3] = tmp & 0x3F;
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
325 angle = 16;
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
326 } else { // retrieve luma samples from codebook
5089
bff60ecc02f9 Use AV_xx throughout libavcodec
ramiro
parents: 4962
diff changeset
327 tmp = bytestream_get_be16(&buf);
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2834
diff changeset
328
2979
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
329 angle = (tmp >> 12) & 0xF;
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
330 tmp &= 0xFFF;
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
331 tmp <<= 2;
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
332 Y[0] = s->ulti_codebook[tmp];
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
333 Y[1] = s->ulti_codebook[tmp + 1];
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
334 Y[2] = s->ulti_codebook[tmp + 2];
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
335 Y[3] = s->ulti_codebook[tmp + 3];
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
336 }
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
337 break;
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2834
diff changeset
338
2979
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
339 case 3:
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
340 if (modifier) { // all 16 luma samples
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
341 uint8_t Luma[16];
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2834
diff changeset
342
5089
bff60ecc02f9 Use AV_xx throughout libavcodec
ramiro
parents: 4962
diff changeset
343 tmp = bytestream_get_be24(&buf);
2979
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
344 Luma[0] = (tmp >> 18) & 0x3F;
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
345 Luma[1] = (tmp >> 12) & 0x3F;
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
346 Luma[2] = (tmp >> 6) & 0x3F;
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
347 Luma[3] = tmp & 0x3F;
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2834
diff changeset
348
5089
bff60ecc02f9 Use AV_xx throughout libavcodec
ramiro
parents: 4962
diff changeset
349 tmp = bytestream_get_be24(&buf);
2979
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
350 Luma[4] = (tmp >> 18) & 0x3F;
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
351 Luma[5] = (tmp >> 12) & 0x3F;
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
352 Luma[6] = (tmp >> 6) & 0x3F;
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
353 Luma[7] = tmp & 0x3F;
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2834
diff changeset
354
5089
bff60ecc02f9 Use AV_xx throughout libavcodec
ramiro
parents: 4962
diff changeset
355 tmp = bytestream_get_be24(&buf);
2979
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
356 Luma[8] = (tmp >> 18) & 0x3F;
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
357 Luma[9] = (tmp >> 12) & 0x3F;
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
358 Luma[10] = (tmp >> 6) & 0x3F;
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
359 Luma[11] = tmp & 0x3F;
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2834
diff changeset
360
5089
bff60ecc02f9 Use AV_xx throughout libavcodec
ramiro
parents: 4962
diff changeset
361 tmp = bytestream_get_be24(&buf);
2979
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
362 Luma[12] = (tmp >> 18) & 0x3F;
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
363 Luma[13] = (tmp >> 12) & 0x3F;
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
364 Luma[14] = (tmp >> 6) & 0x3F;
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
365 Luma[15] = tmp & 0x3F;
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2834
diff changeset
366
2979
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
367 ulti_convert_yuv(&s->frame, tx, ty, Luma, chroma);
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
368 } else {
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
369 tmp = *buf++;
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
370 if(tmp & 0x80) {
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
371 angle = (tmp >> 4) & 0x7;
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
372 tmp = (tmp << 8) + *buf++;
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
373 Y[0] = (tmp >> 6) & 0x3F;
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
374 Y[1] = tmp & 0x3F;
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
375 Y[2] = (*buf++) & 0x3F;
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
376 Y[3] = (*buf++) & 0x3F;
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
377 ulti_grad(&s->frame, tx, ty, Y, chroma, angle); //draw block
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
378 } else { // some patterns
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
379 int f0, f1;
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
380 f0 = *buf++;
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
381 f1 = tmp;
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
382 Y[0] = (*buf++) & 0x3F;
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
383 Y[1] = (*buf++) & 0x3F;
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
384 ulti_pattern(&s->frame, tx, ty, f1, f0, Y[0], Y[1], chroma);
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
385 }
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
386 }
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
387 break;
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
388 }
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
389 if(code != 3)
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
390 ulti_grad(&s->frame, tx, ty, Y, chroma, angle); // draw block
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
391 }
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
392 blocks++;
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
393 x += 8;
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
394 if(x >= s->width) {
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
395 x = 0;
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
396 y += 8;
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
397 }
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
398 }
2234
dff53892ff8a IBM Ultimotion video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
399 }
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2834
diff changeset
400
2234
dff53892ff8a IBM Ultimotion video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
401 *data_size=sizeof(AVFrame);
dff53892ff8a IBM Ultimotion video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
402 *(AVFrame*)data= s->frame;
dff53892ff8a IBM Ultimotion video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
403
dff53892ff8a IBM Ultimotion video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
404 return buf_size;
dff53892ff8a IBM Ultimotion video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
405 }
dff53892ff8a IBM Ultimotion video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
406
dff53892ff8a IBM Ultimotion video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
407 AVCodec ulti_decoder = {
dff53892ff8a IBM Ultimotion video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
408 "ultimotion",
11560
8a4984c5cacc Define AVMediaType enum, and use it instead of enum CodecType, which
stefano
parents: 10413
diff changeset
409 AVMEDIA_TYPE_VIDEO,
2234
dff53892ff8a IBM Ultimotion video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
410 CODEC_ID_ULTI,
dff53892ff8a IBM Ultimotion video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
411 sizeof(UltimotionDecodeContext),
dff53892ff8a IBM Ultimotion video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
412 ulti_decode_init,
dff53892ff8a IBM Ultimotion video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
413 NULL,
10399
136334ad62b3 Release frame after decoding is done
kostya
parents: 10132
diff changeset
414 ulti_decode_end,
2234
dff53892ff8a IBM Ultimotion video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
415 ulti_decode_frame,
dff53892ff8a IBM Ultimotion video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
416 CODEC_CAP_DR1,
6712
5b3acf9fd50a Add long names to AVCodec declarations.
diego
parents: 6517
diff changeset
417 NULL,
7040
e943e1409077 Make AVCodec long_names definition conditional depending on CONFIG_SMALL.
stefano
parents: 6712
diff changeset
418 .long_name = NULL_IF_CONFIG_SMALL("IBM UltiMotion"),
2234
dff53892ff8a IBM Ultimotion video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
419 };
dff53892ff8a IBM Ultimotion video decoder, courtesy of Konstantin Shishkov
melanson
parents:
diff changeset
420