1 /*
2 * 012v decoder
3 *
4 * Copyright (C) 2012 Carl Eugen Hoyos
5 *
6 * This file is part of FFmpeg.
7 *
8 * FFmpeg is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
12 *
13 * FFmpeg is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
17 *
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with FFmpeg; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21 */
22
26
28 {
31
34
35 return 0;
36 }
37
40 {
47
48 if (width == 1) {
51 }
52
55 && avpkt->
size / avctx->
height * 3 >= width * 8)
57
62 }
63
66
69
70 y = (uint16_t *)pic->
data[0];
71 u = (uint16_t *)pic->
data[1];
72 v = (uint16_t *)pic->
data[2];
73 line_end = avpkt->
data + stride;
74
75 while (line++ < avctx->
height) {
76 while (1) {
78 src += 4;
79 *u++ = t << 6 & 0xFFC0;
80 *y++ = t >> 4 & 0xFFC0;
81 *v++ = t >> 14 & 0xFFC0;
82
83 if (src >= line_end - 1) {
84 *y = 0x80;
85 src++;
86 line_end += stride;
87 y = (uint16_t *)(pic->
data[0] + line * pic->
linesize[0]);
88 u = (uint16_t *)(pic->
data[1] + line * pic->
linesize[1]);
89 v = (uint16_t *)(pic->
data[2] + line * pic->
linesize[2]);
90 break;
91 }
92
94 src += 4;
95 *y++ = t << 6 & 0xFFC0;
96 *u++ = t >> 4 & 0xFFC0;
97 *y++ = t >> 14 & 0xFFC0;
98 if (src >= line_end - 2) {
99 if (!(width & 1)) {
100 *y = 0x80;
101 src += 2;
102 }
103 line_end += stride;
104 y = (uint16_t *)(pic->
data[0] + line * pic->
linesize[0]);
105 u = (uint16_t *)(pic->
data[1] + line * pic->
linesize[1]);
106 v = (uint16_t *)(pic->
data[2] + line * pic->
linesize[2]);
107 break;
108 }
109
111 src += 4;
112 *v++ = t << 6 & 0xFFC0;
113 *y++ = t >> 4 & 0xFFC0;
114 *u++ = t >> 14 & 0xFFC0;
115
116 if (src >= line_end - 1) {
117 *y = 0x80;
118 src++;
119 line_end += stride;
120 y = (uint16_t *)(pic->
data[0] + line * pic->
linesize[0]);
121 u = (uint16_t *)(pic->
data[1] + line * pic->
linesize[1]);
122 v = (uint16_t *)(pic->
data[2] + line * pic->
linesize[2]);
123 break;
124 }
125
127 src += 4;
128 *y++ = t << 6 & 0xFFC0;
129 *v++ = t >> 4 & 0xFFC0;
130 *y++ = t >> 14 & 0xFFC0;
131
132 if (src >= line_end - 2) {
133 if (width & 1) {
134 *y = 0x80;
135 src += 2;
136 }
137 line_end += stride;
138 y = (uint16_t *)(pic->
data[0] + line * pic->
linesize[0]);
139 u = (uint16_t *)(pic->
data[1] + line * pic->
linesize[1]);
140 v = (uint16_t *)(pic->
data[2] + line * pic->
linesize[2]);
141 break;
142 }
143 }
144 }
145
146 *got_frame = 1;
147
149 }
150
159 };