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 == 0 || format == 6) {
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 = AV_PICTURE_TYPE_I + 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 < 6) {
00068 s->width = ff_h263_format[format][0];
00069 s->height = ff_h263_format[format][1];
00070 s->avctx->sample_aspect_ratio.num = 12;
00071 s->avctx->sample_aspect_ratio.den = 11;
00072 } else {
00073 format = get_bits(&s->gb, 3);
00074 if(format == 0 || format == 7){
00075 av_log(s->avctx, AV_LOG_ERROR, "Wrong Intel H263 format\n");
00076 return -1;
00077 }
00078 if(get_bits(&s->gb, 2))
00079 av_log(s->avctx, AV_LOG_ERROR, "Bad value for reserved field\n");
00080 s->loop_filter = get_bits1(&s->gb) * !s->avctx->lowres;
00081 if(get_bits1(&s->gb))
00082 av_log(s->avctx, AV_LOG_ERROR, "Bad value for reserved field\n");
00083 if(get_bits1(&s->gb))
00084 s->pb_frame = 2;
00085 if(get_bits(&s->gb, 5))
00086 av_log(s->avctx, AV_LOG_ERROR, "Bad value for reserved field\n");
00087 if(get_bits(&s->gb, 5) != 1)
00088 av_log(s->avctx, AV_LOG_ERROR, "Invalid marker\n");
00089 }
00090 if(format == 6){
00091 int ar = get_bits(&s->gb, 4);
00092 skip_bits(&s->gb, 9);
00093 skip_bits1(&s->gb);
00094 skip_bits(&s->gb, 9);
00095 if(ar == 15){
00096 s->avctx->sample_aspect_ratio.num = get_bits(&s->gb, 8);
00097 s->avctx->sample_aspect_ratio.den = get_bits(&s->gb, 8);
00098 } else {
00099 s->avctx->sample_aspect_ratio = ff_h263_pixel_aspect[ar];
00100 }
00101 if (s->avctx->sample_aspect_ratio.num == 0)
00102 av_log(s->avctx, AV_LOG_ERROR, "Invalid aspect ratio.\n");
00103 }
00104
00105 s->chroma_qscale= s->qscale = get_bits(&s->gb, 5);
00106 skip_bits1(&s->gb);
00107
00108 if(s->pb_frame){
00109 skip_bits(&s->gb, 3);
00110 skip_bits(&s->gb, 2);
00111 }
00112
00113
00114 while (get_bits1(&s->gb) != 0) {
00115 skip_bits(&s->gb, 8);
00116 }
00117 s->f_code = 1;
00118
00119 s->y_dc_scale_table=
00120 s->c_dc_scale_table= ff_mpeg1_dc_scale_table;
00121
00122 ff_h263_show_pict_info(s);
00123
00124 return 0;
00125 }
00126
00127 AVCodec ff_h263i_decoder = {
00128 .name = "h263i",
00129 .type = AVMEDIA_TYPE_VIDEO,
00130 .id = CODEC_ID_H263I,
00131 .priv_data_size = sizeof(MpegEncContext),
00132 .init = ff_h263_decode_init,
00133 .close = ff_h263_decode_end,
00134 .decode = ff_h263_decode_frame,
00135 .capabilities = CODEC_CAP_DRAW_HORIZ_BAND | CODEC_CAP_DR1,
00136 .long_name = NULL_IF_CONFIG_SMALL("Intel H.263"),
00137 .pix_fmts= ff_pixfmt_list_420,
00138 };
00139