10791
|
1 /*
|
|
2 * H.263i decoder
|
|
3 *
|
|
4 * This file is part of FFmpeg.
|
|
5 *
|
|
6 * FFmpeg is free software; you can redistribute it and/or
|
|
7 * modify it under the terms of the GNU Lesser General Public
|
|
8 * License as published by the Free Software Foundation; either
|
|
9 * version 2.1 of the License, or (at your option) any later version.
|
|
10 *
|
|
11 * FFmpeg is distributed in the hope that it will be useful,
|
|
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
14 * Lesser General Public License for more details.
|
|
15 *
|
|
16 * You should have received a copy of the GNU Lesser General Public
|
|
17 * License along with FFmpeg; if not, write to the Free Software
|
|
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
19 */
|
|
20
|
|
21 #include "mpegvideo.h"
|
|
22
|
|
23 /* don't understand why they choose a different header ! */
|
|
24 int ff_intel_h263_decode_picture_header(MpegEncContext *s)
|
|
25 {
|
|
26 int format;
|
|
27
|
|
28 /* picture header */
|
|
29 if (get_bits_long(&s->gb, 22) != 0x20) {
|
|
30 av_log(s->avctx, AV_LOG_ERROR, "Bad picture start code\n");
|
|
31 return -1;
|
|
32 }
|
|
33 s->picture_number = get_bits(&s->gb, 8); /* picture timestamp */
|
|
34
|
|
35 if (get_bits1(&s->gb) != 1) {
|
|
36 av_log(s->avctx, AV_LOG_ERROR, "Bad marker\n");
|
|
37 return -1; /* marker */
|
|
38 }
|
|
39 if (get_bits1(&s->gb) != 0) {
|
|
40 av_log(s->avctx, AV_LOG_ERROR, "Bad H263 id\n");
|
|
41 return -1; /* h263 id */
|
|
42 }
|
|
43 skip_bits1(&s->gb); /* split screen off */
|
|
44 skip_bits1(&s->gb); /* camera off */
|
|
45 skip_bits1(&s->gb); /* freeze picture release off */
|
|
46
|
|
47 format = get_bits(&s->gb, 3);
|
|
48 if (format != 7) {
|
|
49 av_log(s->avctx, AV_LOG_ERROR, "Intel H263 free format not supported\n");
|
|
50 return -1;
|
|
51 }
|
|
52 s->h263_plus = 0;
|
|
53
|
|
54 s->pict_type = FF_I_TYPE + get_bits1(&s->gb);
|
|
55
|
|
56 s->unrestricted_mv = get_bits1(&s->gb);
|
|
57 s->h263_long_vectors = s->unrestricted_mv;
|
|
58
|
|
59 if (get_bits1(&s->gb) != 0) {
|
|
60 av_log(s->avctx, AV_LOG_ERROR, "SAC not supported\n");
|
|
61 return -1; /* SAC: off */
|
|
62 }
|
|
63 s->obmc= get_bits1(&s->gb);
|
|
64 s->pb_frame = get_bits1(&s->gb);
|
|
65
|
|
66 if(format == 7){
|
|
67 format = get_bits(&s->gb, 3);
|
|
68 if(format == 0 || format == 7){
|
|
69 av_log(s->avctx, AV_LOG_ERROR, "Wrong Intel H263 format\n");
|
|
70 return -1;
|
|
71 }
|
|
72 if(get_bits(&s->gb, 2))
|
|
73 av_log(s->avctx, AV_LOG_ERROR, "Bad value for reserved field\n");
|
|
74 s->loop_filter = get_bits1(&s->gb);
|
|
75 if(get_bits1(&s->gb))
|
|
76 av_log(s->avctx, AV_LOG_ERROR, "Bad value for reserved field\n");
|
|
77 if(get_bits1(&s->gb))
|
|
78 s->pb_frame = 2;
|
|
79 if(get_bits(&s->gb, 5))
|
|
80 av_log(s->avctx, AV_LOG_ERROR, "Bad value for reserved field\n");
|
|
81 if(get_bits(&s->gb, 5) != 1)
|
|
82 av_log(s->avctx, AV_LOG_ERROR, "Invalid marker\n");
|
|
83 }
|
|
84 if(format == 6){
|
|
85 int ar = get_bits(&s->gb, 4);
|
|
86 skip_bits(&s->gb, 9); // display width
|
|
87 skip_bits1(&s->gb);
|
|
88 skip_bits(&s->gb, 9); // display height
|
|
89 if(ar == 15){
|
|
90 skip_bits(&s->gb, 8); // aspect ratio - width
|
|
91 skip_bits(&s->gb, 8); // aspect ratio - height
|
|
92 }
|
|
93 }
|
|
94
|
|
95 s->chroma_qscale= s->qscale = get_bits(&s->gb, 5);
|
|
96 skip_bits1(&s->gb); /* Continuous Presence Multipoint mode: off */
|
|
97
|
|
98 if(s->pb_frame){
|
|
99 skip_bits(&s->gb, 3); //temporal reference for B-frame
|
|
100 skip_bits(&s->gb, 2); //dbquant
|
|
101 }
|
|
102
|
|
103 /* PEI */
|
|
104 while (get_bits1(&s->gb) != 0) {
|
|
105 skip_bits(&s->gb, 8);
|
|
106 }
|
|
107 s->f_code = 1;
|
|
108
|
|
109 s->y_dc_scale_table=
|
|
110 s->c_dc_scale_table= ff_mpeg1_dc_scale_table;
|
|
111
|
10812
|
112 ff_h263_show_pict_info(s);
|
10791
|
113
|
|
114 return 0;
|
|
115 }
|
|
116
|
|
117 AVCodec h263i_decoder = {
|
|
118 "h263i",
|
|
119 CODEC_TYPE_VIDEO,
|
|
120 CODEC_ID_H263I,
|
|
121 sizeof(MpegEncContext),
|
|
122 ff_h263_decode_init,
|
|
123 NULL,
|
|
124 ff_h263_decode_end,
|
|
125 ff_h263_decode_frame,
|
|
126 CODEC_CAP_DRAW_HORIZ_BAND | CODEC_CAP_DR1,
|
|
127 .long_name = NULL_IF_CONFIG_SMALL("Intel H.263"),
|
|
128 .pix_fmts= ff_pixfmt_list_420,
|
|
129 };
|
|
130
|