libavcodec/intelh263dec.c

Go to the documentation of this file.
00001 /*
00002  * H.263i decoder
00003  *
00004  * This file is part of FFmpeg.
00005  *
00006  * FFmpeg is free software; you can redistribute it and/or
00007  * modify it under the terms of the GNU Lesser General Public
00008  * License as published by the Free Software Foundation; either
00009  * version 2.1 of the License, or (at your option) any later version.
00010  *
00011  * FFmpeg is distributed in the hope that it will be useful,
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
00014  * Lesser General Public License for more details.
00015  *
00016  * You should have received a copy of the GNU Lesser General Public
00017  * License along with FFmpeg; if not, write to the Free Software
00018  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
00019  */
00020 
00021 #include "mpegvideo.h"
00022 #include "h263.h"
00023 
00024 /* don't understand why they choose a different header ! */
00025 int ff_intel_h263_decode_picture_header(MpegEncContext *s)
00026 {
00027 int format;
00028 
00029 /* picture header */
00030 if (get_bits_long(&s->gb, 22) != 0x20) {
00031 av_log(s->avctx, AV_LOG_ERROR, "Bad picture start code\n");
00032 return -1;
00033 }
00034 s->picture_number = get_bits(&s->gb, 8); /* picture timestamp */
00035 
00036 if (get_bits1(&s->gb) != 1) {
00037 av_log(s->avctx, AV_LOG_ERROR, "Bad marker\n");
00038 return -1; /* marker */
00039 }
00040 if (get_bits1(&s->gb) != 0) {
00041 av_log(s->avctx, AV_LOG_ERROR, "Bad H263 id\n");
00042 return -1; /* h263 id */
00043 }
00044 skip_bits1(&s->gb); /* split screen off */
00045 skip_bits1(&s->gb); /* camera off */
00046 skip_bits1(&s->gb); /* freeze picture release off */
00047 
00048 format = get_bits(&s->gb, 3);
00049 if (format == 0 || format == 6) {
00050 av_log(s->avctx, AV_LOG_ERROR, "Intel H263 free format not supported\n");
00051 return -1;
00052 }
00053 s->h263_plus = 0;
00054 
00055 s->pict_type = AV_PICTURE_TYPE_I + get_bits1(&s->gb);
00056 
00057 s->unrestricted_mv = get_bits1(&s->gb);
00058 s->h263_long_vectors = s->unrestricted_mv;
00059 
00060 if (get_bits1(&s->gb) != 0) {
00061 av_log(s->avctx, AV_LOG_ERROR, "SAC not supported\n");
00062 return -1; /* SAC: off */
00063 }
00064 s->obmc= get_bits1(&s->gb);
00065 s->pb_frame = get_bits1(&s->gb);
00066 
00067 if (format < 6) {
00068 s->width = h263_format[format][0];
00069 s->height = h263_format[format][1];
00070 s->avctx->sample_aspect_ratio.num = 12;
00071 s->avctx->sample_aspect_ratio.den = 11;
00072 } else {
00073 format = get_bits(&s->gb, 3);
00074 if(format == 0 || format == 7){
00075 av_log(s->avctx, AV_LOG_ERROR, "Wrong Intel H263 format\n");
00076 return -1;
00077 }
00078 if(get_bits(&s->gb, 2))
00079 av_log(s->avctx, AV_LOG_ERROR, "Bad value for reserved field\n");
00080 s->loop_filter = get_bits1(&s->gb);
00081 if(get_bits1(&s->gb))
00082 av_log(s->avctx, AV_LOG_ERROR, "Bad value for reserved field\n");
00083 if(get_bits1(&s->gb))
00084 s->pb_frame = 2;
00085 if(get_bits(&s->gb, 5))
00086 av_log(s->avctx, AV_LOG_ERROR, "Bad value for reserved field\n");
00087 if(get_bits(&s->gb, 5) != 1)
00088 av_log(s->avctx, AV_LOG_ERROR, "Invalid marker\n");
00089 }
00090 if(format == 6){
00091 int ar = get_bits(&s->gb, 4);
00092 skip_bits(&s->gb, 9); // display width
00093 skip_bits1(&s->gb);
00094 skip_bits(&s->gb, 9); // display height
00095 if(ar == 15){
00096 s->avctx->sample_aspect_ratio.num = get_bits(&s->gb, 8); // aspect ratio - width
00097 s->avctx->sample_aspect_ratio.den = get_bits(&s->gb, 8); // aspect ratio - height
00098 } else {
00099 s->avctx->sample_aspect_ratio = ff_h263_pixel_aspect[ar];
00100 }
00101 if (s->avctx->sample_aspect_ratio.num == 0)
00102 av_log(s->avctx, AV_LOG_ERROR, "Invalid aspect ratio.\n");
00103 }
00104 
00105 s->chroma_qscale= s->qscale = get_bits(&s->gb, 5);
00106 skip_bits1(&s->gb); /* Continuous Presence Multipoint mode: off */
00107 
00108 if(s->pb_frame){
00109 skip_bits(&s->gb, 3); //temporal reference for B-frame
00110 skip_bits(&s->gb, 2); //dbquant
00111 }
00112 
00113 /* PEI */
00114 while (get_bits1(&s->gb) != 0) {
00115 skip_bits(&s->gb, 8);
00116 }
00117 s->f_code = 1;
00118 
00119 s->y_dc_scale_table=
00120 s->c_dc_scale_table= ff_mpeg1_dc_scale_table;
00121 
00122 ff_h263_show_pict_info(s);
00123 
00124 return 0;
00125 }
00126 
00127 AVCodec ff_h263i_decoder = {
00128 .name = "h263i",
00129 .type = AVMEDIA_TYPE_VIDEO,
00130 .id = CODEC_ID_H263I,
00131 .priv_data_size = sizeof(MpegEncContext),
00132 .init = ff_h263_decode_init,
00133 .close = ff_h263_decode_end,
00134 .decode = ff_h263_decode_frame,
00135 .capabilities = CODEC_CAP_DRAW_HORIZ_BAND | CODEC_CAP_DR1,
00136 .long_name = NULL_IF_CONFIG_SMALL("Intel H.263"),
00137 .pix_fmts= ff_pixfmt_list_420,
00138 };
00139 

Generated on Fri Oct 26 02:43:35 2012 for FFmpeg by doxygen 1.5.8

AltStyle によって変換されたページ (->オリジナル) /