Mercurial > libavcodec.hg
annotate v210x.c @ 10144:50ec8930f99e libavcodec
ff_sine_windows table contains only constant data, too.
author | reimar |
---|---|
date | Sun, 06 Sep 2009 08:56:10 +0000 |
parents | 2f804e0a17fc |
children | 2bb3882075b6 |
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 if(avcodec_check_dimensions(avctx, avctx->width, avctx->height) < 0) |
4a4929da4ddc
Support reading packed YUV422 10bit samples from Sveriges Television AB (SVT)
michael
parents:
diff
changeset
|
31 return -1; |
4a4929da4ddc
Support reading packed YUV422 10bit samples from Sveriges Television AB (SVT)
michael
parents:
diff
changeset
|
32 avctx->pix_fmt = PIX_FMT_YUV422P16; |
4a4929da4ddc
Support reading packed YUV422 10bit samples from Sveriges Television AB (SVT)
michael
parents:
diff
changeset
|
33 avctx->bits_per_raw_sample= 10; |
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 avctx->coded_frame= avcodec_alloc_frame(); |
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 return 0; |
4a4929da4ddc
Support reading packed YUV422 10bit samples from Sveriges Television AB (SVT)
michael
parents:
diff
changeset
|
38 } |
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 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
|
41 { |
4a4929da4ddc
Support reading packed YUV422 10bit samples from Sveriges Television AB (SVT)
michael
parents:
diff
changeset
|
42 int y=0; |
4a4929da4ddc
Support reading packed YUV422 10bit samples from Sveriges Television AB (SVT)
michael
parents:
diff
changeset
|
43 int width= avctx->width; |
4a4929da4ddc
Support reading packed YUV422 10bit samples from Sveriges Television AB (SVT)
michael
parents:
diff
changeset
|
44 AVFrame *pic= avctx->coded_frame; |
9735 | 45 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
|
46 uint16_t *ydst, *udst, *vdst, *yend; |
4a4929da4ddc
Support reading packed YUV422 10bit samples from Sveriges Television AB (SVT)
michael
parents:
diff
changeset
|
47 |
4a4929da4ddc
Support reading packed YUV422 10bit samples from Sveriges Television AB (SVT)
michael
parents:
diff
changeset
|
48 if(pic->data[0]) |
4a4929da4ddc
Support reading packed YUV422 10bit samples from Sveriges Television AB (SVT)
michael
parents:
diff
changeset
|
49 avctx->release_buffer(avctx, pic); |
4a4929da4ddc
Support reading packed YUV422 10bit samples from Sveriges Television AB (SVT)
michael
parents:
diff
changeset
|
50 |
4a4929da4ddc
Support reading packed YUV422 10bit samples from Sveriges Television AB (SVT)
michael
parents:
diff
changeset
|
51 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
|
52 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
|
53 return -1; |
4a4929da4ddc
Support reading packed YUV422 10bit samples from Sveriges Television AB (SVT)
michael
parents:
diff
changeset
|
54 } |
4a4929da4ddc
Support reading packed YUV422 10bit samples from Sveriges Television AB (SVT)
michael
parents:
diff
changeset
|
55 |
4a4929da4ddc
Support reading packed YUV422 10bit samples from Sveriges Television AB (SVT)
michael
parents:
diff
changeset
|
56 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
|
57 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
|
58 } |
4a4929da4ddc
Support reading packed YUV422 10bit samples from Sveriges Television AB (SVT)
michael
parents:
diff
changeset
|
59 |
4a4929da4ddc
Support reading packed YUV422 10bit samples from Sveriges Television AB (SVT)
michael
parents:
diff
changeset
|
60 pic->reference= 0; |
4a4929da4ddc
Support reading packed YUV422 10bit samples from Sveriges Television AB (SVT)
michael
parents:
diff
changeset
|
61 if(avctx->get_buffer(avctx, pic) < 0) |
4a4929da4ddc
Support reading packed YUV422 10bit samples from Sveriges Television AB (SVT)
michael
parents:
diff
changeset
|
62 return -1; |
4a4929da4ddc
Support reading packed YUV422 10bit samples from Sveriges Television AB (SVT)
michael
parents:
diff
changeset
|
63 |
9735 | 64 ydst= (uint16_t *)pic->data[0]; |
65 udst= (uint16_t *)pic->data[1]; | |
66 vdst= (uint16_t *)pic->data[2]; | |
9535
4a4929da4ddc
Support reading packed YUV422 10bit samples from Sveriges Television AB (SVT)
michael
parents:
diff
changeset
|
67 yend= ydst + width; |
4a4929da4ddc
Support reading packed YUV422 10bit samples from Sveriges Television AB (SVT)
michael
parents:
diff
changeset
|
68 pic->pict_type= FF_I_TYPE; |
4a4929da4ddc
Support reading packed YUV422 10bit samples from Sveriges Television AB (SVT)
michael
parents:
diff
changeset
|
69 pic->key_frame= 1; |
4a4929da4ddc
Support reading packed YUV422 10bit samples from Sveriges Television AB (SVT)
michael
parents:
diff
changeset
|
70 |
4a4929da4ddc
Support reading packed YUV422 10bit samples from Sveriges Television AB (SVT)
michael
parents:
diff
changeset
|
71 for(;;){ |
4a4929da4ddc
Support reading packed YUV422 10bit samples from Sveriges Television AB (SVT)
michael
parents:
diff
changeset
|
72 uint32_t v= be2me_32(*src++); |
4a4929da4ddc
Support reading packed YUV422 10bit samples from Sveriges Television AB (SVT)
michael
parents:
diff
changeset
|
73 *udst++= (v>>16) & 0xFFC0; |
4a4929da4ddc
Support reading packed YUV422 10bit samples from Sveriges Television AB (SVT)
michael
parents:
diff
changeset
|
74 *ydst++= (v>>6 ) & 0xFFC0; |
4a4929da4ddc
Support reading packed YUV422 10bit samples from Sveriges Television AB (SVT)
michael
parents:
diff
changeset
|
75 *vdst++= (v<<4 ) & 0xFFC0; |
4a4929da4ddc
Support reading packed YUV422 10bit samples from Sveriges Television AB (SVT)
michael
parents:
diff
changeset
|
76 |
4a4929da4ddc
Support reading packed YUV422 10bit samples from Sveriges Television AB (SVT)
michael
parents:
diff
changeset
|
77 v= be2me_32(*src++); |
4a4929da4ddc
Support reading packed YUV422 10bit samples from Sveriges Television AB (SVT)
michael
parents:
diff
changeset
|
78 *ydst++= (v>>16) & 0xFFC0; |
4a4929da4ddc
Support reading packed YUV422 10bit samples from Sveriges Television AB (SVT)
michael
parents:
diff
changeset
|
79 |
4a4929da4ddc
Support reading packed YUV422 10bit samples from Sveriges Television AB (SVT)
michael
parents:
diff
changeset
|
80 if(ydst >= yend){ |
4a4929da4ddc
Support reading packed YUV422 10bit samples from Sveriges Television AB (SVT)
michael
parents:
diff
changeset
|
81 ydst+= pic->linesize[0]/2 - width; |
4a4929da4ddc
Support reading packed YUV422 10bit samples from Sveriges Television AB (SVT)
michael
parents:
diff
changeset
|
82 udst+= pic->linesize[1]/2 - width/2; |
4a4929da4ddc
Support reading packed YUV422 10bit samples from Sveriges Television AB (SVT)
michael
parents:
diff
changeset
|
83 vdst+= pic->linesize[2]/2 - width/2; |
4a4929da4ddc
Support reading packed YUV422 10bit samples from Sveriges Television AB (SVT)
michael
parents:
diff
changeset
|
84 yend= ydst + width; |
4a4929da4ddc
Support reading packed YUV422 10bit samples from Sveriges Television AB (SVT)
michael
parents:
diff
changeset
|
85 if(++y >= avctx->height) |
4a4929da4ddc
Support reading packed YUV422 10bit samples from Sveriges Television AB (SVT)
michael
parents:
diff
changeset
|
86 break; |
4a4929da4ddc
Support reading packed YUV422 10bit samples from Sveriges Television AB (SVT)
michael
parents:
diff
changeset
|
87 } |
4a4929da4ddc
Support reading packed YUV422 10bit samples from Sveriges Television AB (SVT)
michael
parents:
diff
changeset
|
88 |
4a4929da4ddc
Support reading packed YUV422 10bit samples from Sveriges Television AB (SVT)
michael
parents:
diff
changeset
|
89 *udst++= (v>>6 ) & 0xFFC0; |
4a4929da4ddc
Support reading packed YUV422 10bit samples from Sveriges Television AB (SVT)
michael
parents:
diff
changeset
|
90 *ydst++= (v<<4 ) & 0xFFC0; |
4a4929da4ddc
Support reading packed YUV422 10bit samples from Sveriges Television AB (SVT)
michael
parents:
diff
changeset
|
91 |
4a4929da4ddc
Support reading packed YUV422 10bit samples from Sveriges Television AB (SVT)
michael
parents:
diff
changeset
|
92 v= be2me_32(*src++); |
4a4929da4ddc
Support reading packed YUV422 10bit samples from Sveriges Television AB (SVT)
michael
parents:
diff
changeset
|
93 *vdst++= (v>>16) & 0xFFC0; |
4a4929da4ddc
Support reading packed YUV422 10bit samples from Sveriges Television AB (SVT)
michael
parents:
diff
changeset
|
94 *ydst++= (v>>6 ) & 0xFFC0; |
4a4929da4ddc
Support reading packed YUV422 10bit samples from Sveriges Television AB (SVT)
michael
parents:
diff
changeset
|
95 |
4a4929da4ddc
Support reading packed YUV422 10bit samples from Sveriges Television AB (SVT)
michael
parents:
diff
changeset
|
96 if(ydst >= yend){ |
4a4929da4ddc
Support reading packed YUV422 10bit samples from Sveriges Television AB (SVT)
michael
parents:
diff
changeset
|
97 ydst+= pic->linesize[0]/2 - width; |
4a4929da4ddc
Support reading packed YUV422 10bit samples from Sveriges Television AB (SVT)
michael
parents:
diff
changeset
|
98 udst+= pic->linesize[1]/2 - width/2; |
4a4929da4ddc
Support reading packed YUV422 10bit samples from Sveriges Television AB (SVT)
michael
parents:
diff
changeset
|
99 vdst+= pic->linesize[2]/2 - width/2; |
4a4929da4ddc
Support reading packed YUV422 10bit samples from Sveriges Television AB (SVT)
michael
parents:
diff
changeset
|
100 yend= ydst + width; |
4a4929da4ddc
Support reading packed YUV422 10bit samples from Sveriges Television AB (SVT)
michael
parents:
diff
changeset
|
101 if(++y >= avctx->height) |
4a4929da4ddc
Support reading packed YUV422 10bit samples from Sveriges Television AB (SVT)
michael
parents:
diff
changeset
|
102 break; |
4a4929da4ddc
Support reading packed YUV422 10bit samples from Sveriges Television AB (SVT)
michael
parents:
diff
changeset
|
103 } |
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 *udst++= (v<<4 ) & 0xFFC0; |
4a4929da4ddc
Support reading packed YUV422 10bit samples from Sveriges Television AB (SVT)
michael
parents:
diff
changeset
|
106 |
4a4929da4ddc
Support reading packed YUV422 10bit samples from Sveriges Television AB (SVT)
michael
parents:
diff
changeset
|
107 v= be2me_32(*src++); |
4a4929da4ddc
Support reading packed YUV422 10bit samples from Sveriges Television AB (SVT)
michael
parents:
diff
changeset
|
108 *ydst++= (v>>16) & 0xFFC0; |
4a4929da4ddc
Support reading packed YUV422 10bit samples from Sveriges Television AB (SVT)
michael
parents:
diff
changeset
|
109 *vdst++= (v>>6 ) & 0xFFC0; |
4a4929da4ddc
Support reading packed YUV422 10bit samples from Sveriges Television AB (SVT)
michael
parents:
diff
changeset
|
110 *ydst++= (v<<4 ) & 0xFFC0; |
4a4929da4ddc
Support reading packed YUV422 10bit samples from Sveriges Television AB (SVT)
michael
parents:
diff
changeset
|
111 if(ydst >= yend){ |
4a4929da4ddc
Support reading packed YUV422 10bit samples from Sveriges Television AB (SVT)
michael
parents:
diff
changeset
|
112 ydst+= pic->linesize[0]/2 - width; |
4a4929da4ddc
Support reading packed YUV422 10bit samples from Sveriges Television AB (SVT)
michael
parents:
diff
changeset
|
113 udst+= pic->linesize[1]/2 - width/2; |
4a4929da4ddc
Support reading packed YUV422 10bit samples from Sveriges Television AB (SVT)
michael
parents:
diff
changeset
|
114 vdst+= pic->linesize[2]/2 - width/2; |
4a4929da4ddc
Support reading packed YUV422 10bit samples from Sveriges Television AB (SVT)
michael
parents:
diff
changeset
|
115 yend= ydst + width; |
4a4929da4ddc
Support reading packed YUV422 10bit samples from Sveriges Television AB (SVT)
michael
parents:
diff
changeset
|
116 if(++y >= avctx->height) |
4a4929da4ddc
Support reading packed YUV422 10bit samples from Sveriges Television AB (SVT)
michael
parents:
diff
changeset
|
117 break; |
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 } |
4a4929da4ddc
Support reading packed YUV422 10bit samples from Sveriges Television AB (SVT)
michael
parents:
diff
changeset
|
120 |
4a4929da4ddc
Support reading packed YUV422 10bit samples from Sveriges Television AB (SVT)
michael
parents:
diff
changeset
|
121 *data_size=sizeof(AVFrame); |
4a4929da4ddc
Support reading packed YUV422 10bit samples from Sveriges Television AB (SVT)
michael
parents:
diff
changeset
|
122 *(AVFrame*)data= *avctx->coded_frame; |
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 return avpkt->size; |
4a4929da4ddc
Support reading packed YUV422 10bit samples from Sveriges Television AB (SVT)
michael
parents:
diff
changeset
|
125 } |
4a4929da4ddc
Support reading packed YUV422 10bit samples from Sveriges Television AB (SVT)
michael
parents:
diff
changeset
|
126 |
4a4929da4ddc
Support reading packed YUV422 10bit samples from Sveriges Television AB (SVT)
michael
parents:
diff
changeset
|
127 AVCodec v210x_decoder = { |
4a4929da4ddc
Support reading packed YUV422 10bit samples from Sveriges Television AB (SVT)
michael
parents:
diff
changeset
|
128 "v210x", |
4a4929da4ddc
Support reading packed YUV422 10bit samples from Sveriges Television AB (SVT)
michael
parents:
diff
changeset
|
129 CODEC_TYPE_VIDEO, |
4a4929da4ddc
Support reading packed YUV422 10bit samples from Sveriges Television AB (SVT)
michael
parents:
diff
changeset
|
130 CODEC_ID_V210X, |
4a4929da4ddc
Support reading packed YUV422 10bit samples from Sveriges Television AB (SVT)
michael
parents:
diff
changeset
|
131 0, |
4a4929da4ddc
Support reading packed YUV422 10bit samples from Sveriges Television AB (SVT)
michael
parents:
diff
changeset
|
132 decode_init, |
4a4929da4ddc
Support reading packed YUV422 10bit samples from Sveriges Television AB (SVT)
michael
parents:
diff
changeset
|
133 NULL, |
4a4929da4ddc
Support reading packed YUV422 10bit samples from Sveriges Television AB (SVT)
michael
parents:
diff
changeset
|
134 NULL, |
4a4929da4ddc
Support reading packed YUV422 10bit samples from Sveriges Television AB (SVT)
michael
parents:
diff
changeset
|
135 decode_frame, |
4a4929da4ddc
Support reading packed YUV422 10bit samples from Sveriges Television AB (SVT)
michael
parents:
diff
changeset
|
136 CODEC_CAP_DR1, |
4a4929da4ddc
Support reading packed YUV422 10bit samples from Sveriges Television AB (SVT)
michael
parents:
diff
changeset
|
137 }; |