00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
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));
00032 put_bits(&s->pb, 8, (((int64_t)s->picture_number * 30 * s->avctx->time_base.num) /
00033 s->avctx->time_base.den) & 0xff);
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;
00046 else
00047 format = 1;
00048 put_bits(&s->pb, 3, format);
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 == AV_PICTURE_TYPE_P);
00057 put_bits(&s->pb, 1, 1);
00058 put_bits(&s->pb, 5, s->qscale);
00059 put_bits(&s->pb, 1, 0);
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) {
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
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 ff_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 };