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_flv2_decode_ac_esc(GetBitContext *gb, int *level, int *run, int *last){
00025 int is11 = get_bits1(gb);
00026 *last = get_bits1(gb);
00027 *run = get_bits(gb, 6);
00028 if(is11){
00029 *level = get_sbits(gb, 11);
00030 } else {
00031 *level = get_sbits(gb, 7);
00032 }
00033 }
00034
00035 int ff_flv_decode_picture_header(MpegEncContext *s)
00036 {
00037 int format, width, height;
00038
00039
00040 if (get_bits_long(&s->gb, 17) != 1) {
00041 av_log(s->avctx, AV_LOG_ERROR, "Bad picture start code\n");
00042 return -1;
00043 }
00044 format = get_bits(&s->gb, 5);
00045 if (format != 0 && format != 1) {
00046 av_log(s->avctx, AV_LOG_ERROR, "Bad picture format\n");
00047 return -1;
00048 }
00049 s->h263_flv = format+1;
00050 s->picture_number = get_bits(&s->gb, 8);
00051 format = get_bits(&s->gb, 3);
00052 switch (format) {
00053 case 0:
00054 width = get_bits(&s->gb, 8);
00055 height = get_bits(&s->gb, 8);
00056 break;
00057 case 1:
00058 width = get_bits(&s->gb, 16);
00059 height = get_bits(&s->gb, 16);
00060 break;
00061 case 2:
00062 width = 352;
00063 height = 288;
00064 break;
00065 case 3:
00066 width = 176;
00067 height = 144;
00068 break;
00069 case 4:
00070 width = 128;
00071 height = 96;
00072 break;
00073 case 5:
00074 width = 320;
00075 height = 240;
00076 break;
00077 case 6:
00078 width = 160;
00079 height = 120;
00080 break;
00081 default:
00082 width = height = 0;
00083 break;
00084 }
00085 if(avcodec_check_dimensions(s->avctx, width, height))
00086 return -1;
00087 s->width = width;
00088 s->height = height;
00089
00090 s->pict_type = FF_I_TYPE + get_bits(&s->gb, 2);
00091 s->dropable= s->pict_type > FF_P_TYPE;
00092 if (s->dropable)
00093 s->pict_type = FF_P_TYPE;
00094
00095 skip_bits1(&s->gb);
00096 s->chroma_qscale= s->qscale = get_bits(&s->gb, 5);
00097
00098 s->h263_plus = 0;
00099
00100 s->unrestricted_mv = 1;
00101 s->h263_long_vectors = 0;
00102
00103
00104 while (get_bits1(&s->gb) != 0) {
00105 skip_bits(&s->gb, 8);
00106 }
00107 s->f_code = 1;
00108
00109 if(s->avctx->debug & FF_DEBUG_PICT_INFO){
00110 av_log(s->avctx, AV_LOG_DEBUG, "%c esc_type:%d, qp:%d num:%d\n",
00111 s->dropable ? 'D' : av_get_pict_type_char(s->pict_type), s->h263_flv-1, s->qscale, s->picture_number);
00112 }
00113
00114 s->y_dc_scale_table=
00115 s->c_dc_scale_table= ff_mpeg1_dc_scale_table;
00116
00117 return 0;
00118 }
00119
00120 AVCodec flv_decoder = {
00121 "flv",
00122 AVMEDIA_TYPE_VIDEO,
00123 CODEC_ID_FLV1,
00124 sizeof(MpegEncContext),
00125 ff_h263_decode_init,
00126 NULL,
00127 ff_h263_decode_end,
00128 ff_h263_decode_frame,
00129 CODEC_CAP_DRAW_HORIZ_BAND | CODEC_CAP_DR1,
00130 .long_name= NULL_IF_CONFIG_SMALL("Flash Video (FLV) / Sorenson Spark / Sorenson H.263"),
00131 .pix_fmts= ff_pixfmt_list_420,
00132 };