Mercurial > libavcodec.hg
annotate v210x.c @ 11514:2a8845a2687f libavcodec
fix compilation with --disable-everything --enable-decoder=mpeg2video
author | aurel |
---|---|
date | Sat, 20 Mar 2010 23:18:07 +0000 |
parents | fbeb4ea31f87 |
children | 8a4984c5cacc |
rev | line source |
---|---|
9535
4a4929da4ddc
Support reading packed YUV422 10bit samples from Sveriges Television AB (SVT)
michael
parents:
diff
changeset
|
1 /* |
4a4929da4ddc
Support reading packed YUV422 10bit samples from Sveriges Television AB (SVT)
michael
parents:
diff
changeset
|
2 * Copyright (C) 2009 Michael Niedermayer <michaelni@gmx.at> |
4a4929da4ddc
Support reading packed YUV422 10bit samples from Sveriges Television AB (SVT)
michael
parents:
diff
changeset
|
3 * |
4a4929da4ddc
Support reading packed YUV422 10bit samples from Sveriges Television AB (SVT)
michael
parents:
diff
changeset
|
4 * This file is part of FFmpeg. |
4a4929da4ddc
Support reading packed YUV422 10bit samples from Sveriges Television AB (SVT)
michael
parents:
diff
changeset
|
5 * |
4a4929da4ddc
Support reading packed YUV422 10bit samples from Sveriges Television AB (SVT)
michael
parents:
diff
changeset
|
6 * FFmpeg is free software; you can redistribute it and/or |
4a4929da4ddc
Support reading packed YUV422 10bit samples from Sveriges Television AB (SVT)
michael
parents:
diff
changeset
|
7 * modify it under the terms of the GNU Lesser General Public |
4a4929da4ddc
Support reading packed YUV422 10bit samples from Sveriges Television AB (SVT)
michael
parents:
diff
changeset
|
8 * License as published by the Free Software Foundation; either |
4a4929da4ddc
Support reading packed YUV422 10bit samples from Sveriges Television AB (SVT)
michael
parents:
diff
changeset
|
9 * version 2.1 of the License, or (at your option) any later version. |
4a4929da4ddc
Support reading packed YUV422 10bit samples from Sveriges Television AB (SVT)
michael
parents:
diff
changeset
|
10 * |
4a4929da4ddc
Support reading packed YUV422 10bit samples from Sveriges Television AB (SVT)
michael
parents:
diff
changeset
|
11 * FFmpeg is distributed in the hope that it will be useful, |
4a4929da4ddc
Support reading packed YUV422 10bit samples from Sveriges Television AB (SVT)
michael
parents:
diff
changeset
|
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
4a4929da4ddc
Support reading packed YUV422 10bit samples from Sveriges Television AB (SVT)
michael
parents:
diff
changeset
|
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
4a4929da4ddc
Support reading packed YUV422 10bit samples from Sveriges Television AB (SVT)
michael
parents:
diff
changeset
|
14 * Lesser General Public License for more details. |
4a4929da4ddc
Support reading packed YUV422 10bit samples from Sveriges Television AB (SVT)
michael
parents:
diff
changeset
|
15 * |
4a4929da4ddc
Support reading packed YUV422 10bit samples from Sveriges Television AB (SVT)
michael
parents:
diff
changeset
|
16 * You should have received a copy of the GNU Lesser General Public |
4a4929da4ddc
Support reading packed YUV422 10bit samples from Sveriges Television AB (SVT)
michael
parents:
diff
changeset
|
17 * License along with FFmpeg; if not, write to the Free Software |
4a4929da4ddc
Support reading packed YUV422 10bit samples from Sveriges Television AB (SVT)
michael
parents:
diff
changeset
|
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
4a4929da4ddc
Support reading packed YUV422 10bit samples from Sveriges Television AB (SVT)
michael
parents:
diff
changeset
|
19 */ |
4a4929da4ddc
Support reading packed YUV422 10bit samples from Sveriges Television AB (SVT)
michael
parents:
diff
changeset
|
20 |
4a4929da4ddc
Support reading packed YUV422 10bit samples from Sveriges Television AB (SVT)
michael
parents:
diff
changeset
|
21 #include "avcodec.h" |
4a4929da4ddc
Support reading packed YUV422 10bit samples from Sveriges Television AB (SVT)
michael
parents:
diff
changeset
|
22 #include "libavutil/bswap.h" |
4a4929da4ddc
Support reading packed YUV422 10bit samples from Sveriges Television AB (SVT)
michael
parents:
diff
changeset
|
23 |
4a4929da4ddc
Support reading packed YUV422 10bit samples from Sveriges Television AB (SVT)
michael
parents:
diff
changeset
|
24 static av_cold int decode_init(AVCodecContext *avctx) |
4a4929da4ddc
Support reading packed YUV422 10bit samples from Sveriges Television AB (SVT)
michael
parents:
diff
changeset
|
25 { |
4a4929da4ddc
Support reading packed YUV422 10bit samples from Sveriges Television AB (SVT)
michael
parents:
diff
changeset
|
26 if(avctx->width & 1){ |
4a4929da4ddc
Support reading packed YUV422 10bit samples from Sveriges Television AB (SVT)
michael
parents:
diff
changeset
|
27 av_log(avctx, AV_LOG_ERROR, "v210x needs even width\n"); |
4a4929da4ddc
Support reading packed YUV422 10bit samples from Sveriges Television AB (SVT)
michael
parents:
diff
changeset
|
28 return -1; |
4a4929da4ddc
Support reading packed YUV422 10bit samples from Sveriges Television AB (SVT)
michael
parents:
diff
changeset
|
29 } |
4a4929da4ddc
Support reading packed YUV422 10bit samples from Sveriges Television AB (SVT)
michael
parents:
diff
changeset
|
30 avctx->pix_fmt = PIX_FMT_YUV422P16; |
4a4929da4ddc
Support reading packed YUV422 10bit samples from Sveriges Television AB (SVT)
michael
parents:
diff
changeset
|
31 avctx->bits_per_raw_sample= 10; |
4a4929da4ddc
Support reading packed YUV422 10bit samples from Sveriges Television AB (SVT)
michael
parents:
diff
changeset
|
32 |
4a4929da4ddc
Support reading packed YUV422 10bit samples from Sveriges Television AB (SVT)
michael
parents:
diff
changeset
|
33 avctx->coded_frame= avcodec_alloc_frame(); |
4a4929da4ddc
Support reading packed YUV422 10bit samples from Sveriges Television AB (SVT)
michael
parents:
diff
changeset
|
34 |
4a4929da4ddc
Support reading packed YUV422 10bit samples from Sveriges Television AB (SVT)
michael
parents:
diff
changeset
|
35 return 0; |
4a4929da4ddc
Support reading packed YUV422 10bit samples from Sveriges Television AB (SVT)
michael
parents:
diff
changeset
|
36 } |
4a4929da4ddc
Support reading packed YUV422 10bit samples from Sveriges Television AB (SVT)
michael
parents:
diff
changeset
|
37 |
4a4929da4ddc
Support reading packed YUV422 10bit samples from Sveriges Television AB (SVT)
michael
parents:
diff
changeset
|
38 static int decode_frame(AVCodecContext *avctx, void *data, int *data_size, AVPacket *avpkt) |
4a4929da4ddc
Support reading packed YUV422 10bit samples from Sveriges Television AB (SVT)
michael
parents:
diff
changeset
|
39 { |
4a4929da4ddc
Support reading packed YUV422 10bit samples from Sveriges Television AB (SVT)
michael
parents:
diff
changeset
|
40 int y=0; |
4a4929da4ddc
Support reading packed YUV422 10bit samples from Sveriges Television AB (SVT)
michael
parents:
diff
changeset
|
41 int width= avctx->width; |
4a4929da4ddc
Support reading packed YUV422 10bit samples from Sveriges Television AB (SVT)
michael
parents:
diff
changeset
|
42 AVFrame *pic= avctx->coded_frame; |
9735 | 43 const uint32_t *src= (const uint32_t *)avpkt->data; |
9535
4a4929da4ddc
Support reading packed YUV422 10bit samples from Sveriges Television AB (SVT)
michael
parents:
diff
changeset
|
44 uint16_t *ydst, *udst, *vdst, *yend; |
4a4929da4ddc
Support reading packed YUV422 10bit samples from Sveriges Television AB (SVT)
michael
parents:
diff
changeset
|
45 |
4a4929da4ddc
Support reading packed YUV422 10bit samples from Sveriges Television AB (SVT)
michael
parents:
diff
changeset
|
46 if(pic->data[0]) |
4a4929da4ddc
Support reading packed YUV422 10bit samples from Sveriges Television AB (SVT)
michael
parents:
diff
changeset
|
47 avctx->release_buffer(avctx, pic); |
4a4929da4ddc
Support reading packed YUV422 10bit samples from Sveriges Television AB (SVT)
michael
parents:
diff
changeset
|
48 |
4a4929da4ddc
Support reading packed YUV422 10bit samples from Sveriges Television AB (SVT)
michael
parents:
diff
changeset
|
49 if(avpkt->size < avctx->width * avctx->height * 8 / 3){ |
4a4929da4ddc
Support reading packed YUV422 10bit samples from Sveriges Television AB (SVT)
michael
parents:
diff
changeset
|
50 av_log(avctx, AV_LOG_ERROR, "Packet too small\n"); |
4a4929da4ddc
Support reading packed YUV422 10bit samples from Sveriges Television AB (SVT)
michael
parents:
diff
changeset
|
51 return -1; |
4a4929da4ddc
Support reading packed YUV422 10bit samples from Sveriges Television AB (SVT)
michael
parents:
diff
changeset
|
52 } |
4a4929da4ddc
Support reading packed YUV422 10bit samples from Sveriges Television AB (SVT)
michael
parents:
diff
changeset
|
53 |
4a4929da4ddc
Support reading packed YUV422 10bit samples from Sveriges Television AB (SVT)
michael
parents:
diff
changeset
|
54 if(avpkt->size > avctx->width * avctx->height * 8 / 3){ |
4a4929da4ddc
Support reading packed YUV422 10bit samples from Sveriges Television AB (SVT)
michael
parents:
diff
changeset
|
55 av_log(avctx, AV_LOG_ERROR, "Probably padded data, need sample!\n"); |
4a4929da4ddc
Support reading packed YUV422 10bit samples from Sveriges Television AB (SVT)
michael
parents:
diff
changeset
|
56 } |
4a4929da4ddc
Support reading packed YUV422 10bit samples from Sveriges Television AB (SVT)
michael
parents:
diff
changeset
|
57 |
4a4929da4ddc
Support reading packed YUV422 10bit samples from Sveriges Television AB (SVT)
michael
parents:
diff
changeset
|
58 pic->reference= 0; |
4a4929da4ddc
Support reading packed YUV422 10bit samples from Sveriges Television AB (SVT)
michael
parents:
diff
changeset
|
59 if(avctx->get_buffer(avctx, pic) < 0) |
4a4929da4ddc
Support reading packed YUV422 10bit samples from Sveriges Television AB (SVT)
michael
parents:
diff
changeset
|
60 return -1; |
4a4929da4ddc
Support reading packed YUV422 10bit samples from Sveriges Television AB (SVT)
michael
parents:
diff
changeset
|
61 |
9735 | 62 ydst= (uint16_t *)pic->data[0]; |
63 udst= (uint16_t *)pic->data[1]; | |
64 vdst= (uint16_t *)pic->data[2]; | |
9535
4a4929da4ddc
Support reading packed YUV422 10bit samples from Sveriges Television AB (SVT)
michael
parents:
diff
changeset
|
65 yend= ydst + width; |
4a4929da4ddc
Support reading packed YUV422 10bit samples from Sveriges Television AB (SVT)
michael
parents:
diff
changeset
|
66 pic->pict_type= FF_I_TYPE; |
4a4929da4ddc
Support reading packed YUV422 10bit samples from Sveriges Television AB (SVT)
michael
parents:
diff
changeset
|
67 pic->key_frame= 1; |
4a4929da4ddc
Support reading packed YUV422 10bit samples from Sveriges Television AB (SVT)
michael
parents:
diff
changeset
|
68 |
4a4929da4ddc
Support reading packed YUV422 10bit samples from Sveriges Television AB (SVT)
michael
parents:
diff
changeset
|
69 for(;;){ |
4a4929da4ddc
Support reading packed YUV422 10bit samples from Sveriges Television AB (SVT)
michael
parents:
diff
changeset
|
70 uint32_t v= be2me_32(*src++); |
4a4929da4ddc
Support reading packed YUV422 10bit samples from Sveriges Television AB (SVT)
michael
parents:
diff
changeset
|
71 *udst++= (v>>16) & 0xFFC0; |
4a4929da4ddc
Support reading packed YUV422 10bit samples from Sveriges Television AB (SVT)
michael
parents:
diff
changeset
|
72 *ydst++= (v>>6 ) & 0xFFC0; |
4a4929da4ddc
Support reading packed YUV422 10bit samples from Sveriges Television AB (SVT)
michael
parents:
diff
changeset
|
73 *vdst++= (v<<4 ) & 0xFFC0; |
4a4929da4ddc
Support reading packed YUV422 10bit samples from Sveriges Television AB (SVT)
michael
parents:
diff
changeset
|
74 |
4a4929da4ddc
Support reading packed YUV422 10bit samples from Sveriges Television AB (SVT)
michael
parents:
diff
changeset
|
75 v= be2me_32(*src++); |
4a4929da4ddc
Support reading packed YUV422 10bit samples from Sveriges Television AB (SVT)
michael
parents:
diff
changeset
|
76 *ydst++= (v>>16) & 0xFFC0; |
4a4929da4ddc
Support reading packed YUV422 10bit samples from Sveriges Television AB (SVT)
michael
parents:
diff
changeset
|
77 |
4a4929da4ddc
Support reading packed YUV422 10bit samples from Sveriges Television AB (SVT)
michael
parents:
diff
changeset
|
78 if(ydst >= yend){ |
4a4929da4ddc
Support reading packed YUV422 10bit samples from Sveriges Television AB (SVT)
michael
parents:
diff
changeset
|
79 ydst+= pic->linesize[0]/2 - width; |
4a4929da4ddc
Support reading packed YUV422 10bit samples from Sveriges Television AB (SVT)
michael
parents:
diff
changeset
|
80 udst+= pic->linesize[1]/2 - width/2; |
4a4929da4ddc
Support reading packed YUV422 10bit samples from Sveriges Television AB (SVT)
michael
parents:
diff
changeset
|
81 vdst+= pic->linesize[2]/2 - width/2; |
4a4929da4ddc
Support reading packed YUV422 10bit samples from Sveriges Television AB (SVT)
michael
parents:
diff
changeset
|
82 yend= ydst + width; |
4a4929da4ddc
Support reading packed YUV422 10bit samples from Sveriges Television AB (SVT)
michael
parents:
diff
changeset
|
83 if(++y >= avctx->height) |
4a4929da4ddc
Support reading packed YUV422 10bit samples from Sveriges Television AB (SVT)
michael
parents:
diff
changeset
|
84 break; |
4a4929da4ddc
Support reading packed YUV422 10bit samples from Sveriges Television AB (SVT)
michael
parents:
diff
changeset
|
85 } |
4a4929da4ddc
Support reading packed YUV422 10bit samples from Sveriges Television AB (SVT)
michael
parents:
diff
changeset
|
86 |
4a4929da4ddc
Support reading packed YUV422 10bit samples from Sveriges Television AB (SVT)
michael
parents:
diff
changeset
|
87 *udst++= (v>>6 ) & 0xFFC0; |
4a4929da4ddc
Support reading packed YUV422 10bit samples from Sveriges Television AB (SVT)
michael
parents:
diff
changeset
|
88 *ydst++= (v<<4 ) & 0xFFC0; |
4a4929da4ddc
Support reading packed YUV422 10bit samples from Sveriges Television AB (SVT)
michael
parents:
diff
changeset
|
89 |
4a4929da4ddc
Support reading packed YUV422 10bit samples from Sveriges Television AB (SVT)
michael
parents:
diff
changeset
|
90 v= be2me_32(*src++); |
4a4929da4ddc
Support reading packed YUV422 10bit samples from Sveriges Television AB (SVT)
michael
parents:
diff
changeset
|
91 *vdst++= (v>>16) & 0xFFC0; |
4a4929da4ddc
Support reading packed YUV422 10bit samples from Sveriges Television AB (SVT)
michael
parents:
diff
changeset
|
92 *ydst++= (v>>6 ) & 0xFFC0; |
4a4929da4ddc
Support reading packed YUV422 10bit samples from Sveriges Television AB (SVT)
michael
parents:
diff
changeset
|
93 |
4a4929da4ddc
Support reading packed YUV422 10bit samples from Sveriges Television AB (SVT)
michael
parents:
diff
changeset
|
94 if(ydst >= yend){ |
4a4929da4ddc
Support reading packed YUV422 10bit samples from Sveriges Television AB (SVT)
michael
parents:
diff
changeset
|
95 ydst+= pic->linesize[0]/2 - width; |
4a4929da4ddc
Support reading packed YUV422 10bit samples from Sveriges Television AB (SVT)
michael
parents:
diff
changeset
|
96 udst+= pic->linesize[1]/2 - width/2; |
4a4929da4ddc
Support reading packed YUV422 10bit samples from Sveriges Television AB (SVT)
michael
parents:
diff
changeset
|
97 vdst+= pic->linesize[2]/2 - width/2; |
4a4929da4ddc
Support reading packed YUV422 10bit samples from Sveriges Television AB (SVT)
michael
parents:
diff
changeset
|
98 yend= ydst + width; |
4a4929da4ddc
Support reading packed YUV422 10bit samples from Sveriges Television AB (SVT)
michael
parents:
diff
changeset
|
99 if(++y >= avctx->height) |
4a4929da4ddc
Support reading packed YUV422 10bit samples from Sveriges Television AB (SVT)
michael
parents:
diff
changeset
|
100 break; |
4a4929da4ddc
Support reading packed YUV422 10bit samples from Sveriges Television AB (SVT)
michael
parents:
diff
changeset
|
101 } |
4a4929da4ddc
Support reading packed YUV422 10bit samples from Sveriges Television AB (SVT)
michael
parents:
diff
changeset
|
102 |
4a4929da4ddc
Support reading packed YUV422 10bit samples from Sveriges Television AB (SVT)
michael
parents:
diff
changeset
|
103 *udst++= (v<<4 ) & 0xFFC0; |
4a4929da4ddc
Support reading packed YUV422 10bit samples from Sveriges Television AB (SVT)
michael
parents:
diff
changeset
|
104 |
4a4929da4ddc
Support reading packed YUV422 10bit samples from Sveriges Television AB (SVT)
michael
parents:
diff
changeset
|
105 v= be2me_32(*src++); |
4a4929da4ddc
Support reading packed YUV422 10bit samples from Sveriges Television AB (SVT)
michael
parents:
diff
changeset
|
106 *ydst++= (v>>16) & 0xFFC0; |
4a4929da4ddc
Support reading packed YUV422 10bit samples from Sveriges Television AB (SVT)
michael
parents:
diff
changeset
|
107 *vdst++= (v>>6 ) & 0xFFC0; |
4a4929da4ddc
Support reading packed YUV422 10bit samples from Sveriges Television AB (SVT)
michael
parents:
diff
changeset
|
108 *ydst++= (v<<4 ) & 0xFFC0; |
4a4929da4ddc
Support reading packed YUV422 10bit samples from Sveriges Television AB (SVT)
michael
parents:
diff
changeset
|
109 if(ydst >= yend){ |
4a4929da4ddc
Support reading packed YUV422 10bit samples from Sveriges Television AB (SVT)
michael
parents:
diff
changeset
|
110 ydst+= pic->linesize[0]/2 - width; |
4a4929da4ddc
Support reading packed YUV422 10bit samples from Sveriges Television AB (SVT)
michael
parents:
diff
changeset
|
111 udst+= pic->linesize[1]/2 - width/2; |
4a4929da4ddc
Support reading packed YUV422 10bit samples from Sveriges Television AB (SVT)
michael
parents:
diff
changeset
|
112 vdst+= pic->linesize[2]/2 - width/2; |
4a4929da4ddc
Support reading packed YUV422 10bit samples from Sveriges Television AB (SVT)
michael
parents:
diff
changeset
|
113 yend= ydst + width; |
4a4929da4ddc
Support reading packed YUV422 10bit samples from Sveriges Television AB (SVT)
michael
parents:
diff
changeset
|
114 if(++y >= avctx->height) |
4a4929da4ddc
Support reading packed YUV422 10bit samples from Sveriges Television AB (SVT)
michael
parents:
diff
changeset
|
115 break; |
4a4929da4ddc
Support reading packed YUV422 10bit samples from Sveriges Television AB (SVT)
michael
parents:
diff
changeset
|
116 } |
4a4929da4ddc
Support reading packed YUV422 10bit samples from Sveriges Television AB (SVT)
michael
parents:
diff
changeset
|
117 } |
4a4929da4ddc
Support reading packed YUV422 10bit samples from Sveriges Television AB (SVT)
michael
parents:
diff
changeset
|
118 |
4a4929da4ddc
Support reading packed YUV422 10bit samples from Sveriges Television AB (SVT)
michael
parents:
diff
changeset
|
119 *data_size=sizeof(AVFrame); |
4a4929da4ddc
Support reading packed YUV422 10bit samples from Sveriges Television AB (SVT)
michael
parents:
diff
changeset
|
120 *(AVFrame*)data= *avctx->coded_frame; |
4a4929da4ddc
Support reading packed YUV422 10bit samples from Sveriges Television AB (SVT)
michael
parents:
diff
changeset
|
121 |
4a4929da4ddc
Support reading packed YUV422 10bit samples from Sveriges Television AB (SVT)
michael
parents:
diff
changeset
|
122 return avpkt->size; |
4a4929da4ddc
Support reading packed YUV422 10bit samples from Sveriges Television AB (SVT)
michael
parents:
diff
changeset
|
123 } |
4a4929da4ddc
Support reading packed YUV422 10bit samples from Sveriges Television AB (SVT)
michael
parents:
diff
changeset
|
124 |
10396 | 125 static av_cold int decode_close(AVCodecContext *avctx) |
126 { | |
127 AVFrame *pic = avctx->coded_frame; | |
128 if (pic->data[0]) | |
129 avctx->release_buffer(avctx, pic); | |
130 av_freep(&avctx->coded_frame); | |
131 | |
132 return 0; | |
133 } | |
134 | |
9535
4a4929da4ddc
Support reading packed YUV422 10bit samples from Sveriges Television AB (SVT)
michael
parents:
diff
changeset
|
135 AVCodec v210x_decoder = { |
4a4929da4ddc
Support reading packed YUV422 10bit samples from Sveriges Television AB (SVT)
michael
parents:
diff
changeset
|
136 "v210x", |
4a4929da4ddc
Support reading packed YUV422 10bit samples from Sveriges Television AB (SVT)
michael
parents:
diff
changeset
|
137 CODEC_TYPE_VIDEO, |
4a4929da4ddc
Support reading packed YUV422 10bit samples from Sveriges Television AB (SVT)
michael
parents:
diff
changeset
|
138 CODEC_ID_V210X, |
4a4929da4ddc
Support reading packed YUV422 10bit samples from Sveriges Television AB (SVT)
michael
parents:
diff
changeset
|
139 0, |
4a4929da4ddc
Support reading packed YUV422 10bit samples from Sveriges Television AB (SVT)
michael
parents:
diff
changeset
|
140 decode_init, |
4a4929da4ddc
Support reading packed YUV422 10bit samples from Sveriges Television AB (SVT)
michael
parents:
diff
changeset
|
141 NULL, |
10396 | 142 decode_close, |
9535
4a4929da4ddc
Support reading packed YUV422 10bit samples from Sveriges Television AB (SVT)
michael
parents:
diff
changeset
|
143 decode_frame, |
4a4929da4ddc
Support reading packed YUV422 10bit samples from Sveriges Television AB (SVT)
michael
parents:
diff
changeset
|
144 CODEC_CAP_DR1, |
11065 | 145 .long_name = NULL_IF_CONFIG_SMALL("Uncompressed 4:2:2 10-bit"), |
9535
4a4929da4ddc
Support reading packed YUV422 10bit samples from Sveriges Television AB (SVT)
michael
parents:
diff
changeset
|
146 }; |