00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #include "mpegvideo.h"
00022 #include "h263.h"
00023
00024
00025 int ff_intel_h263_decode_picture_header(MpegEncContext *s)
00026 {
00027 int format;
00028
00029
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);
00035
00036 if (get_bits1(&s->gb) != 1) {
00037 av_log(s->avctx, AV_LOG_ERROR, "Bad marker\n");
00038 return -1;
00039 }
00040 if (get_bits1(&s->gb) != 0) {
00041 av_log(s->avctx, AV_LOG_ERROR, "Bad H263 id\n");
00042 return -1;
00043 }
00044 skip_bits1(&s->gb);
00045 skip_bits1(&s->gb);
00046 skip_bits1(&s->gb);
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;
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) * !s->avctx->lowres;
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);
00088 skip_bits1(&s->gb);
00089 skip_bits(&s->gb, 9);
00090 if(ar == 15){
00091 skip_bits(&s->gb, 8);
00092 skip_bits(&s->gb, 8);
00093 }
00094 }
00095
00096 s->chroma_qscale= s->qscale = get_bits(&s->gb, 5);
00097 skip_bits1(&s->gb);
00098
00099 if(s->pb_frame){
00100 skip_bits(&s->gb, 3);
00101 skip_bits(&s->gb, 2);
00102 }
00103
00104
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