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

libavcodec/flvenc.c

Go to the documentation of this file.
00001 /*
00002  * FLV Encoding specific code.
00003  * This file is part of FFmpeg.
00004  *
00005  * FFmpeg 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  * FFmpeg 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 FFmpeg; 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 
00024 void ff_flv_encode_picture_header(MpegEncContext * s, int picture_number)
00025 {
00026       int format;
00027 
00028       align_put_bits(&s->pb);
00029 
00030       put_bits(&s->pb, 17, 1);
00031       put_bits(&s->pb, 5, (s->h263_flv-1)); /* 0: h263 escape codes 1: 11-bit escape codes */
00032       put_bits(&s->pb, 8, (((int64_t)s->picture_number * 30 * s->avctx->time_base.num) / //FIXME use timestamp
00033                            s->avctx->time_base.den) & 0xff); /* TemporalReference */
00034       if (s->width == 352 && s->height == 288)
00035         format = 2;
00036       else if (s->width == 176 && s->height == 144)
00037         format = 3;
00038       else if (s->width == 128 && s->height == 96)
00039         format = 4;
00040       else if (s->width == 320 && s->height == 240)
00041         format = 5;
00042       else if (s->width == 160 && s->height == 120)
00043         format = 6;
00044       else if (s->width <= 255 && s->height <= 255)
00045         format = 0; /* use 1 byte width & height */
00046       else
00047         format = 1; /* use 2 bytes width & height */
00048       put_bits(&s->pb, 3, format); /* PictureSize */
00049       if (format == 0) {
00050         put_bits(&s->pb, 8, s->width);
00051         put_bits(&s->pb, 8, s->height);
00052       } else if (format == 1) {
00053         put_bits(&s->pb, 16, s->width);
00054         put_bits(&s->pb, 16, s->height);
00055       }
00056       put_bits(&s->pb, 2, s->pict_type == FF_P_TYPE); /* PictureType */
00057       put_bits(&s->pb, 1, 1); /* DeblockingFlag: on */
00058       put_bits(&s->pb, 5, s->qscale); /* Quantizer */
00059       put_bits(&s->pb, 1, 0); /* ExtraInformation */
00060 
00061       if(s->h263_aic){
00062         s->y_dc_scale_table=
00063           s->c_dc_scale_table= ff_aic_dc_scale_table;
00064       }else{
00065         s->y_dc_scale_table=
00066           s->c_dc_scale_table= ff_mpeg1_dc_scale_table;
00067       }
00068 }
00069 
00070 void ff_flv2_encode_ac_esc(PutBitContext *pb, int slevel, int level, int run, int last){
00071     if(level < 64) { // 7-bit level
00072         put_bits(pb, 1, 0);
00073         put_bits(pb, 1, last);
00074         put_bits(pb, 6, run);
00075 
00076         put_sbits(pb, 7, slevel);
00077     } else {
00078         /* 11-bit level */
00079         put_bits(pb, 1, 1);
00080         put_bits(pb, 1, last);
00081         put_bits(pb, 6, run);
00082 
00083         put_sbits(pb, 11, slevel);
00084     }
00085 }
00086 
00087 AVCodec flv_encoder = {
00088     "flv",
00089     AVMEDIA_TYPE_VIDEO,
00090     CODEC_ID_FLV1,
00091     sizeof(MpegEncContext),
00092     MPV_encode_init,
00093     MPV_encode_picture,
00094     MPV_encode_end,
00095     .pix_fmts= (const enum PixelFormat[]){PIX_FMT_YUV420P, PIX_FMT_NONE},
00096     .long_name= NULL_IF_CONFIG_SMALL("Flash Video (FLV) / Sorenson Spark / Sorenson H.263"),
00097 };

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