FFmpeg coverage


Directory: ../../../ffmpeg/
File: src/libavcodec/intelh263dec.c
Date: 2022-01-18 10:05:52
Exec Total Coverage
Lines: 0 70 0.0%
Branches: 0 40 0.0%

Line Branch Exec Source
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 "mpegutils.h"
22 #include "mpegvideo.h"
23 #include "h263.h"
24 #include "mpegvideodata.h"
25
26 /* don't understand why they choose a different header ! */
27 int ff_intel_h263_decode_picture_header(MpegEncContext *s)
28 {
29 int format;
30
31 if (get_bits_left(&s->gb) == 64) { /* special dummy frames */
32 return FRAME_SKIPPED;
33 }
34
35 /* picture header */
36 if (get_bits(&s->gb, 22) != 0x20) {
37 av_log(s->avctx, AV_LOG_ERROR, "Bad picture start code\n");
38 return -1;
39 }
40 s->picture_number = get_bits(&s->gb, 8); /* picture timestamp */
41
42 if (check_marker(s->avctx, &s->gb, "after picture_number") != 1) {
43 return -1; /* marker */
44 }
45 if (get_bits1(&s->gb) != 0) {
46 av_log(s->avctx, AV_LOG_ERROR, "Bad H.263 id\n");
47 return -1; /* H.263 id */
48 }
49 skip_bits1(&s->gb); /* split screen off */
50 skip_bits1(&s->gb); /* camera off */
51 skip_bits1(&s->gb); /* freeze picture release off */
52
53 format = get_bits(&s->gb, 3);
54 if (format == 0 || format == 6) {
55 av_log(s->avctx, AV_LOG_ERROR, "Intel H.263 free format not supported\n");
56 return -1;
57 }
58 s->h263_plus = 0;
59
60 s->pict_type = AV_PICTURE_TYPE_I + get_bits1(&s->gb);
61
62 s->h263_long_vectors = get_bits1(&s->gb);
63
64 if (get_bits1(&s->gb) != 0) {
65 av_log(s->avctx, AV_LOG_ERROR, "SAC not supported\n");
66 return -1; /* SAC: off */
67 }
68 s->obmc= get_bits1(&s->gb);
69 s->pb_frame = get_bits1(&s->gb);
70
71 if (format < 6) {
72 s->width = ff_h263_format[format][0];
73 s->height = ff_h263_format[format][1];
74 s->avctx->sample_aspect_ratio.num = 12;
75 s->avctx->sample_aspect_ratio.den = 11;
76 } else {
77 format = get_bits(&s->gb, 3);
78 if(format == 0 || format == 7){
79 av_log(s->avctx, AV_LOG_ERROR, "Wrong Intel H.263 format\n");
80 return -1;
81 }
82 if(get_bits(&s->gb, 2))
83 av_log(s->avctx, AV_LOG_ERROR, "Bad value for reserved field\n");
84 s->loop_filter = get_bits1(&s->gb) * !s->avctx->lowres;
85 if(get_bits1(&s->gb))
86 av_log(s->avctx, AV_LOG_ERROR, "Bad value for reserved field\n");
87 if(get_bits1(&s->gb))
88 s->pb_frame = 2;
89 if(get_bits(&s->gb, 5))
90 av_log(s->avctx, AV_LOG_ERROR, "Bad value for reserved field\n");
91 if(get_bits(&s->gb, 5) != 1)
92 av_log(s->avctx, AV_LOG_ERROR, "Invalid marker\n");
93 }
94 if(format == 6){
95 int ar = get_bits(&s->gb, 4);
96 skip_bits(&s->gb, 9); // display width
97 check_marker(s->avctx, &s->gb, "in dimensions");
98 skip_bits(&s->gb, 9); // display height
99 if(ar == 15){
100 s->avctx->sample_aspect_ratio.num = get_bits(&s->gb, 8); // aspect ratio - width
101 s->avctx->sample_aspect_ratio.den = get_bits(&s->gb, 8); // aspect ratio - height
102 } else {
103 s->avctx->sample_aspect_ratio = ff_h263_pixel_aspect[ar];
104 }
105 if (s->avctx->sample_aspect_ratio.num == 0)
106 av_log(s->avctx, AV_LOG_ERROR, "Invalid aspect ratio.\n");
107 }
108
109 s->chroma_qscale= s->qscale = get_bits(&s->gb, 5);
110 skip_bits1(&s->gb); /* Continuous Presence Multipoint mode: off */
111
112 if(s->pb_frame){
113 skip_bits(&s->gb, 3); //temporal reference for B-frame
114 skip_bits(&s->gb, 2); //dbquant
115 }
116
117 /* PEI */
118 if (skip_1stop_8data_bits(&s->gb) < 0)
119 return AVERROR_INVALIDDATA;
120 s->f_code = 1;
121
122 s->y_dc_scale_table=
123 s->c_dc_scale_table= ff_mpeg1_dc_scale_table;
124
125 ff_h263_show_pict_info(s);
126
127 return 0;
128 }
129
130 const AVCodec ff_h263i_decoder = {
131 .name = "h263i",
132 .long_name = NULL_IF_CONFIG_SMALL("Intel H.263"),
133 .type = AVMEDIA_TYPE_VIDEO,
134 .id = AV_CODEC_ID_H263I,
135 .priv_data_size = sizeof(MpegEncContext),
136 .init = ff_h263_decode_init,
137 .close = ff_h263_decode_end,
138 .decode = ff_h263_decode_frame,
139 .capabilities = AV_CODEC_CAP_DRAW_HORIZ_BAND | AV_CODEC_CAP_DR1,
140 .caps_internal = FF_CODEC_CAP_SKIP_FRAME_FILL_PARAM,
141 .pix_fmts = (const enum AVPixelFormat[]) {
142 AV_PIX_FMT_YUV420P,
143 AV_PIX_FMT_NONE
144 },
145 };
146