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

libavcodec/flvdec.c

Go to the documentation of this file.
00001 /*
00002  * FLV decoding.
00003  * This file is part of Libav.
00004  *
00005  * Libav is free software; you can redistribute it and/or
00006  * modify it under the terms of the GNU Lesser General Public
00007  * License as published by the Free Software Foundation; either
00008  * version 2.1 of the License, or (at your option) any later version.
00009  *
00010  * Libav is distributed in the hope that it will be useful,
00011  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013  * Lesser General Public License for more details.
00014  *
00015  * You should have received a copy of the GNU Lesser General Public
00016  * License along with Libav; if not, write to the Free Software
00017  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
00018  */
00019 
00020 #include "mpegvideo.h"
00021 #include "h263.h"
00022 #include "flv.h"
00023 #include "libavutil/imgutils.h"
00024 
00025 void ff_flv2_decode_ac_esc(GetBitContext *gb, int *level, int *run, int *last){
00026     int is11 = get_bits1(gb);
00027     *last = get_bits1(gb);
00028     *run = get_bits(gb, 6);
00029     if(is11){
00030         *level = get_sbits(gb, 11);
00031     } else {
00032         *level = get_sbits(gb, 7);
00033     }
00034 }
00035 
00036 int ff_flv_decode_picture_header(MpegEncContext *s)
00037 {
00038     int format, width, height;
00039 
00040     /* picture header */
00041     if (get_bits_long(&s->gb, 17) != 1) {
00042         av_log(s->avctx, AV_LOG_ERROR, "Bad picture start code\n");
00043         return -1;
00044     }
00045     format = get_bits(&s->gb, 5);
00046     if (format != 0 && format != 1) {
00047         av_log(s->avctx, AV_LOG_ERROR, "Bad picture format\n");
00048         return -1;
00049     }
00050     s->h263_flv = format+1;
00051     s->picture_number = get_bits(&s->gb, 8); /* picture timestamp */
00052     format = get_bits(&s->gb, 3);
00053     switch (format) {
00054     case 0:
00055         width = get_bits(&s->gb, 8);
00056         height = get_bits(&s->gb, 8);
00057         break;
00058     case 1:
00059         width = get_bits(&s->gb, 16);
00060         height = get_bits(&s->gb, 16);
00061         break;
00062     case 2:
00063         width = 352;
00064         height = 288;
00065         break;
00066     case 3:
00067         width = 176;
00068         height = 144;
00069         break;
00070     case 4:
00071         width = 128;
00072         height = 96;
00073         break;
00074     case 5:
00075         width = 320;
00076         height = 240;
00077         break;
00078     case 6:
00079         width = 160;
00080         height = 120;
00081         break;
00082     default:
00083         width = height = 0;
00084         break;
00085     }
00086     if(av_image_check_size(width, height, 0, s->avctx))
00087         return -1;
00088     s->width = width;
00089     s->height = height;
00090 
00091     s->pict_type = AV_PICTURE_TYPE_I + get_bits(&s->gb, 2);
00092     s->dropable= s->pict_type > AV_PICTURE_TYPE_P;
00093     if (s->dropable)
00094         s->pict_type = AV_PICTURE_TYPE_P;
00095 
00096     skip_bits1(&s->gb); /* deblocking flag */
00097     s->chroma_qscale= s->qscale = get_bits(&s->gb, 5);
00098 
00099     s->h263_plus = 0;
00100 
00101     s->unrestricted_mv = 1;
00102     s->h263_long_vectors = 0;
00103 
00104     /* PEI */
00105     while (get_bits1(&s->gb) != 0) {
00106         skip_bits(&s->gb, 8);
00107     }
00108     s->f_code = 1;
00109 
00110     if(s->avctx->debug & FF_DEBUG_PICT_INFO){
00111         av_log(s->avctx, AV_LOG_DEBUG, "%c esc_type:%d, qp:%d num:%d\n",
00112                s->dropable ? 'D' : av_get_picture_type_char(s->pict_type), s->h263_flv-1, s->qscale, s->picture_number);
00113     }
00114 
00115     s->y_dc_scale_table=
00116     s->c_dc_scale_table= ff_mpeg1_dc_scale_table;
00117 
00118     return 0;
00119 }
00120 
00121 AVCodec ff_flv_decoder = {
00122     .name           = "flv",
00123     .type           = AVMEDIA_TYPE_VIDEO,
00124     .id             = CODEC_ID_FLV1,
00125     .priv_data_size = sizeof(MpegEncContext),
00126     .init           = ff_h263_decode_init,
00127     .close          = ff_h263_decode_end,
00128     .decode         = ff_h263_decode_frame,
00129     .capabilities   = CODEC_CAP_DRAW_HORIZ_BAND | CODEC_CAP_DR1,
00130     .max_lowres= 3,
00131     .long_name= NULL_IF_CONFIG_SMALL("Flash Video (FLV) / Sorenson Spark / Sorenson H.263"),
00132     .pix_fmts= ff_pixfmt_list_420,
00133 };
Generated on Sat Mar 17 2012 12:57:44 for Libav by doxygen 1.7.1