• Main Page
  • Related Pages
  • Modules
  • Data Structures
  • Files
  • File List
  • Globals

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 != 7) {
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 = FF_I_TYPE + 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 == 7){
00068         format = get_bits(&s->gb, 3);
00069         if(format == 0 || format == 7){
00070             av_log(s->avctx, AV_LOG_ERROR, "Wrong Intel H263 format\n");
00071             return -1;
00072         }
00073         if(get_bits(&s->gb, 2))
00074             av_log(s->avctx, AV_LOG_ERROR, "Bad value for reserved field\n");
00075         s->loop_filter = get_bits1(&s->gb);
00076         if(get_bits1(&s->gb))
00077             av_log(s->avctx, AV_LOG_ERROR, "Bad value for reserved field\n");
00078         if(get_bits1(&s->gb))
00079             s->pb_frame = 2;
00080         if(get_bits(&s->gb, 5))
00081             av_log(s->avctx, AV_LOG_ERROR, "Bad value for reserved field\n");
00082         if(get_bits(&s->gb, 5) != 1)
00083             av_log(s->avctx, AV_LOG_ERROR, "Invalid marker\n");
00084     }
00085     if(format == 6){
00086         int ar = get_bits(&s->gb, 4);
00087         skip_bits(&s->gb, 9); // display width
00088         skip_bits1(&s->gb);
00089         skip_bits(&s->gb, 9); // display height
00090         if(ar == 15){
00091             skip_bits(&s->gb, 8); // aspect ratio - width
00092             skip_bits(&s->gb, 8); // aspect ratio - height
00093         }
00094     }
00095 
00096     s->chroma_qscale= s->qscale = get_bits(&s->gb, 5);
00097     skip_bits1(&s->gb); /* Continuous Presence Multipoint mode: off */
00098 
00099     if(s->pb_frame){
00100         skip_bits(&s->gb, 3); //temporal reference for B-frame
00101         skip_bits(&s->gb, 2); //dbquant
00102     }
00103 
00104     /* PEI */
00105     while (get_bits1(&s->gb) != 0) {
00106         skip_bits(&s->gb, 8);
00107     }
00108     s->f_code = 1;
00109 
00110     s->y_dc_scale_table=
00111     s->c_dc_scale_table= ff_mpeg1_dc_scale_table;
00112 
00113     ff_h263_show_pict_info(s);
00114 
00115     return 0;
00116 }
00117 
00118 AVCodec h263i_decoder = {
00119     "h263i",
00120     AVMEDIA_TYPE_VIDEO,
00121     CODEC_ID_H263I,
00122     sizeof(MpegEncContext),
00123     ff_h263_decode_init,
00124     NULL,
00125     ff_h263_decode_end,
00126     ff_h263_decode_frame,
00127     CODEC_CAP_DRAW_HORIZ_BAND | CODEC_CAP_DR1,
00128     .long_name = NULL_IF_CONFIG_SMALL("Intel H.263"),
00129     .pix_fmts= ff_pixfmt_list_420,
00130 };
00131 

Generated on Fri Sep 16 2011 17:17:38 for FFmpeg by  doxygen 1.7.1