annotate flvdec.c @ 12515:307776e26174 libavcodec

Support deinterlacing of YUVJ422P in old deinterlacer. Patch by Maksym Veremeyenko verem at m1stereo tv.
author banan
date Sat, 25 Sep 2010 14:37:54 +0000
parents ffb3668ff7af
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
10788
0c8f9288b5e4 Split flv decoding out.
michael
parents:
diff changeset
1 /*
0c8f9288b5e4 Split flv decoding out.
michael
parents:
diff changeset
2 * FLV decoding.
0c8f9288b5e4 Split flv decoding out.
michael
parents:
diff changeset
3 * This file is part of FFmpeg.
0c8f9288b5e4 Split flv decoding out.
michael
parents:
diff changeset
4 *
0c8f9288b5e4 Split flv decoding out.
michael
parents:
diff changeset
5 * FFmpeg is free software; you can redistribute it and/or
0c8f9288b5e4 Split flv decoding out.
michael
parents:
diff changeset
6 * modify it under the terms of the GNU Lesser General Public
0c8f9288b5e4 Split flv decoding out.
michael
parents:
diff changeset
7 * License as published by the Free Software Foundation; either
0c8f9288b5e4 Split flv decoding out.
michael
parents:
diff changeset
8 * version 2.1 of the License, or (at your option) any later version.
0c8f9288b5e4 Split flv decoding out.
michael
parents:
diff changeset
9 *
0c8f9288b5e4 Split flv decoding out.
michael
parents:
diff changeset
10 * FFmpeg is distributed in the hope that it will be useful,
0c8f9288b5e4 Split flv decoding out.
michael
parents:
diff changeset
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
0c8f9288b5e4 Split flv decoding out.
michael
parents:
diff changeset
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
0c8f9288b5e4 Split flv decoding out.
michael
parents:
diff changeset
13 * Lesser General Public License for more details.
0c8f9288b5e4 Split flv decoding out.
michael
parents:
diff changeset
14 *
0c8f9288b5e4 Split flv decoding out.
michael
parents:
diff changeset
15 * You should have received a copy of the GNU Lesser General Public
0c8f9288b5e4 Split flv decoding out.
michael
parents:
diff changeset
16 * License along with FFmpeg; if not, write to the Free Software
0c8f9288b5e4 Split flv decoding out.
michael
parents:
diff changeset
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
0c8f9288b5e4 Split flv decoding out.
michael
parents:
diff changeset
18 */
0c8f9288b5e4 Split flv decoding out.
michael
parents:
diff changeset
19
0c8f9288b5e4 Split flv decoding out.
michael
parents:
diff changeset
20 #include "mpegvideo.h"
10828
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents: 10790
diff changeset
21 #include "h263.h"
10790
145b62a1de1c flv.h should ideally be included in flvdec.c
michael
parents: 10788
diff changeset
22 #include "flv.h"
12372
914f484bb476 Remove use of the deprecated function avcodec_check_dimensions(), use
stefano
parents: 12108
diff changeset
23 #include "libavcore/imgutils.h"
10788
0c8f9288b5e4 Split flv decoding out.
michael
parents:
diff changeset
24
0c8f9288b5e4 Split flv decoding out.
michael
parents:
diff changeset
25 void ff_flv2_decode_ac_esc(GetBitContext *gb, int *level, int *run, int *last){
0c8f9288b5e4 Split flv decoding out.
michael
parents:
diff changeset
26 int is11 = get_bits1(gb);
0c8f9288b5e4 Split flv decoding out.
michael
parents:
diff changeset
27 *last = get_bits1(gb);
0c8f9288b5e4 Split flv decoding out.
michael
parents:
diff changeset
28 *run = get_bits(gb, 6);
0c8f9288b5e4 Split flv decoding out.
michael
parents:
diff changeset
29 if(is11){
0c8f9288b5e4 Split flv decoding out.
michael
parents:
diff changeset
30 *level = get_sbits(gb, 11);
0c8f9288b5e4 Split flv decoding out.
michael
parents:
diff changeset
31 } else {
0c8f9288b5e4 Split flv decoding out.
michael
parents:
diff changeset
32 *level = get_sbits(gb, 7);
0c8f9288b5e4 Split flv decoding out.
michael
parents:
diff changeset
33 }
0c8f9288b5e4 Split flv decoding out.
michael
parents:
diff changeset
34 }
0c8f9288b5e4 Split flv decoding out.
michael
parents:
diff changeset
35
0c8f9288b5e4 Split flv decoding out.
michael
parents:
diff changeset
36 int ff_flv_decode_picture_header(MpegEncContext *s)
0c8f9288b5e4 Split flv decoding out.
michael
parents:
diff changeset
37 {
0c8f9288b5e4 Split flv decoding out.
michael
parents:
diff changeset
38 int format, width, height;
0c8f9288b5e4 Split flv decoding out.
michael
parents:
diff changeset
39
0c8f9288b5e4 Split flv decoding out.
michael
parents:
diff changeset
40 /* picture header */
0c8f9288b5e4 Split flv decoding out.
michael
parents:
diff changeset
41 if (get_bits_long(&s->gb, 17) != 1) {
0c8f9288b5e4 Split flv decoding out.
michael
parents:
diff changeset
42 av_log(s->avctx, AV_LOG_ERROR, "Bad picture start code\n");
0c8f9288b5e4 Split flv decoding out.
michael
parents:
diff changeset
43 return -1;
0c8f9288b5e4 Split flv decoding out.
michael
parents:
diff changeset
44 }
0c8f9288b5e4 Split flv decoding out.
michael
parents:
diff changeset
45 format = get_bits(&s->gb, 5);
0c8f9288b5e4 Split flv decoding out.
michael
parents:
diff changeset
46 if (format != 0 && format != 1) {
0c8f9288b5e4 Split flv decoding out.
michael
parents:
diff changeset
47 av_log(s->avctx, AV_LOG_ERROR, "Bad picture format\n");
0c8f9288b5e4 Split flv decoding out.
michael
parents:
diff changeset
48 return -1;
0c8f9288b5e4 Split flv decoding out.
michael
parents:
diff changeset
49 }
0c8f9288b5e4 Split flv decoding out.
michael
parents:
diff changeset
50 s->h263_flv = format+1;
0c8f9288b5e4 Split flv decoding out.
michael
parents:
diff changeset
51 s->picture_number = get_bits(&s->gb, 8); /* picture timestamp */
0c8f9288b5e4 Split flv decoding out.
michael
parents:
diff changeset
52 format = get_bits(&s->gb, 3);
0c8f9288b5e4 Split flv decoding out.
michael
parents:
diff changeset
53 switch (format) {
0c8f9288b5e4 Split flv decoding out.
michael
parents:
diff changeset
54 case 0:
0c8f9288b5e4 Split flv decoding out.
michael
parents:
diff changeset
55 width = get_bits(&s->gb, 8);
0c8f9288b5e4 Split flv decoding out.
michael
parents:
diff changeset
56 height = get_bits(&s->gb, 8);
0c8f9288b5e4 Split flv decoding out.
michael
parents:
diff changeset
57 break;
0c8f9288b5e4 Split flv decoding out.
michael
parents:
diff changeset
58 case 1:
0c8f9288b5e4 Split flv decoding out.
michael
parents:
diff changeset
59 width = get_bits(&s->gb, 16);
0c8f9288b5e4 Split flv decoding out.
michael
parents:
diff changeset
60 height = get_bits(&s->gb, 16);
0c8f9288b5e4 Split flv decoding out.
michael
parents:
diff changeset
61 break;
0c8f9288b5e4 Split flv decoding out.
michael
parents:
diff changeset
62 case 2:
0c8f9288b5e4 Split flv decoding out.
michael
parents:
diff changeset
63 width = 352;
0c8f9288b5e4 Split flv decoding out.
michael
parents:
diff changeset
64 height = 288;
0c8f9288b5e4 Split flv decoding out.
michael
parents:
diff changeset
65 break;
0c8f9288b5e4 Split flv decoding out.
michael
parents:
diff changeset
66 case 3:
0c8f9288b5e4 Split flv decoding out.
michael
parents:
diff changeset
67 width = 176;
0c8f9288b5e4 Split flv decoding out.
michael
parents:
diff changeset
68 height = 144;
0c8f9288b5e4 Split flv decoding out.
michael
parents:
diff changeset
69 break;
0c8f9288b5e4 Split flv decoding out.
michael
parents:
diff changeset
70 case 4:
0c8f9288b5e4 Split flv decoding out.
michael
parents:
diff changeset
71 width = 128;
0c8f9288b5e4 Split flv decoding out.
michael
parents:
diff changeset
72 height = 96;
0c8f9288b5e4 Split flv decoding out.
michael
parents:
diff changeset
73 break;
0c8f9288b5e4 Split flv decoding out.
michael
parents:
diff changeset
74 case 5:
0c8f9288b5e4 Split flv decoding out.
michael
parents:
diff changeset
75 width = 320;
0c8f9288b5e4 Split flv decoding out.
michael
parents:
diff changeset
76 height = 240;
0c8f9288b5e4 Split flv decoding out.
michael
parents:
diff changeset
77 break;
0c8f9288b5e4 Split flv decoding out.
michael
parents:
diff changeset
78 case 6:
0c8f9288b5e4 Split flv decoding out.
michael
parents:
diff changeset
79 width = 160;
0c8f9288b5e4 Split flv decoding out.
michael
parents:
diff changeset
80 height = 120;
0c8f9288b5e4 Split flv decoding out.
michael
parents:
diff changeset
81 break;
0c8f9288b5e4 Split flv decoding out.
michael
parents:
diff changeset
82 default:
0c8f9288b5e4 Split flv decoding out.
michael
parents:
diff changeset
83 width = height = 0;
0c8f9288b5e4 Split flv decoding out.
michael
parents:
diff changeset
84 break;
0c8f9288b5e4 Split flv decoding out.
michael
parents:
diff changeset
85 }
12462
ffb3668ff7af Use new imgutils.h API names, fix deprecation warnings.
stefano
parents: 12372
diff changeset
86 if(av_image_check_size(width, height, 0, s->avctx))
10788
0c8f9288b5e4 Split flv decoding out.
michael
parents:
diff changeset
87 return -1;
0c8f9288b5e4 Split flv decoding out.
michael
parents:
diff changeset
88 s->width = width;
0c8f9288b5e4 Split flv decoding out.
michael
parents:
diff changeset
89 s->height = height;
0c8f9288b5e4 Split flv decoding out.
michael
parents:
diff changeset
90
0c8f9288b5e4 Split flv decoding out.
michael
parents:
diff changeset
91 s->pict_type = FF_I_TYPE + get_bits(&s->gb, 2);
0c8f9288b5e4 Split flv decoding out.
michael
parents:
diff changeset
92 s->dropable= s->pict_type > FF_P_TYPE;
0c8f9288b5e4 Split flv decoding out.
michael
parents:
diff changeset
93 if (s->dropable)
0c8f9288b5e4 Split flv decoding out.
michael
parents:
diff changeset
94 s->pict_type = FF_P_TYPE;
0c8f9288b5e4 Split flv decoding out.
michael
parents:
diff changeset
95
0c8f9288b5e4 Split flv decoding out.
michael
parents:
diff changeset
96 skip_bits1(&s->gb); /* deblocking flag */
0c8f9288b5e4 Split flv decoding out.
michael
parents:
diff changeset
97 s->chroma_qscale= s->qscale = get_bits(&s->gb, 5);
0c8f9288b5e4 Split flv decoding out.
michael
parents:
diff changeset
98
0c8f9288b5e4 Split flv decoding out.
michael
parents:
diff changeset
99 s->h263_plus = 0;
0c8f9288b5e4 Split flv decoding out.
michael
parents:
diff changeset
100
0c8f9288b5e4 Split flv decoding out.
michael
parents:
diff changeset
101 s->unrestricted_mv = 1;
0c8f9288b5e4 Split flv decoding out.
michael
parents:
diff changeset
102 s->h263_long_vectors = 0;
0c8f9288b5e4 Split flv decoding out.
michael
parents:
diff changeset
103
0c8f9288b5e4 Split flv decoding out.
michael
parents:
diff changeset
104 /* PEI */
0c8f9288b5e4 Split flv decoding out.
michael
parents:
diff changeset
105 while (get_bits1(&s->gb) != 0) {
0c8f9288b5e4 Split flv decoding out.
michael
parents:
diff changeset
106 skip_bits(&s->gb, 8);
0c8f9288b5e4 Split flv decoding out.
michael
parents:
diff changeset
107 }
0c8f9288b5e4 Split flv decoding out.
michael
parents:
diff changeset
108 s->f_code = 1;
0c8f9288b5e4 Split flv decoding out.
michael
parents:
diff changeset
109
0c8f9288b5e4 Split flv decoding out.
michael
parents:
diff changeset
110 if(s->avctx->debug & FF_DEBUG_PICT_INFO){
0c8f9288b5e4 Split flv decoding out.
michael
parents:
diff changeset
111 av_log(s->avctx, AV_LOG_DEBUG, "%c esc_type:%d, qp:%d num:%d\n",
0c8f9288b5e4 Split flv decoding out.
michael
parents:
diff changeset
112 s->dropable ? 'D' : av_get_pict_type_char(s->pict_type), s->h263_flv-1, s->qscale, s->picture_number);
0c8f9288b5e4 Split flv decoding out.
michael
parents:
diff changeset
113 }
0c8f9288b5e4 Split flv decoding out.
michael
parents:
diff changeset
114
0c8f9288b5e4 Split flv decoding out.
michael
parents:
diff changeset
115 s->y_dc_scale_table=
0c8f9288b5e4 Split flv decoding out.
michael
parents:
diff changeset
116 s->c_dc_scale_table= ff_mpeg1_dc_scale_table;
0c8f9288b5e4 Split flv decoding out.
michael
parents:
diff changeset
117
0c8f9288b5e4 Split flv decoding out.
michael
parents:
diff changeset
118 return 0;
0c8f9288b5e4 Split flv decoding out.
michael
parents:
diff changeset
119 }
0c8f9288b5e4 Split flv decoding out.
michael
parents:
diff changeset
120
0c8f9288b5e4 Split flv decoding out.
michael
parents:
diff changeset
121 AVCodec flv_decoder = {
0c8f9288b5e4 Split flv decoding out.
michael
parents:
diff changeset
122 "flv",
11560
8a4984c5cacc Define AVMediaType enum, and use it instead of enum CodecType, which
stefano
parents: 10828
diff changeset
123 AVMEDIA_TYPE_VIDEO,
10788
0c8f9288b5e4 Split flv decoding out.
michael
parents:
diff changeset
124 CODEC_ID_FLV1,
0c8f9288b5e4 Split flv decoding out.
michael
parents:
diff changeset
125 sizeof(MpegEncContext),
0c8f9288b5e4 Split flv decoding out.
michael
parents:
diff changeset
126 ff_h263_decode_init,
0c8f9288b5e4 Split flv decoding out.
michael
parents:
diff changeset
127 NULL,
0c8f9288b5e4 Split flv decoding out.
michael
parents:
diff changeset
128 ff_h263_decode_end,
0c8f9288b5e4 Split flv decoding out.
michael
parents:
diff changeset
129 ff_h263_decode_frame,
0c8f9288b5e4 Split flv decoding out.
michael
parents:
diff changeset
130 CODEC_CAP_DRAW_HORIZ_BAND | CODEC_CAP_DR1,
12108
c35d7bc64882 Add new decoder property max_lowres and do not init decoder if requested value is higher.
cehoyos
parents: 11560
diff changeset
131 .max_lowres= 3,
10788
0c8f9288b5e4 Split flv decoding out.
michael
parents:
diff changeset
132 .long_name= NULL_IF_CONFIG_SMALL("Flash Video (FLV) / Sorenson Spark / Sorenson H.263"),
0c8f9288b5e4 Split flv decoding out.
michael
parents:
diff changeset
133 .pix_fmts= ff_pixfmt_list_420,
0c8f9288b5e4 Split flv decoding out.
michael
parents:
diff changeset
134 };