~gma500/+junk/emgd160

« back to all changes in this revision

Viewing changes to mplayer-vaapi/ffmpeg/libavcodec/intelh263dec.c

  • Committer: Luca Forina
  • Date: 2011-05-03 09:34:53 UTC
  • Revision ID: luca.forina@gmail.com-20110503093453-p1l4o1ck3g67vrha
added mplayer-vaapi

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * H.263i decoder
 
3
 *
 
4
 * This file is part of FFmpeg.
 
5
 *
 
6
 * FFmpeg is free software; you can redistribute it and/or
 
7
 * modify it under the terms of the GNU Lesser General Public
 
8
 * License as published by the Free Software Foundation; either
 
9
 * version 2.1 of the License, or (at your option) any later version.
 
10
 *
 
11
 * FFmpeg is distributed in the hope that it will be useful,
 
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 
14
 * Lesser General Public License for more details.
 
15
 *
 
16
 * You should have received a copy of the GNU Lesser General Public
 
17
 * License along with FFmpeg; if not, write to the Free Software
 
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
 
19
 */
 
20
 
 
21
#include "mpegvideo.h"
 
22
#include "h263.h"
 
23
 
 
24
/* don't understand why they choose a different header ! */
 
25
int ff_intel_h263_decode_picture_header(MpegEncContext *s)
 
26
{
 
27
    int format;
 
28
 
 
29
    /* picture header */
 
30
    if (get_bits_long(&s->gb, 22) != 0x20) {
 
31
        av_log(s->avctx, AV_LOG_ERROR, "Bad picture start code\n");
 
32
        return -1;
 
33
    }
 
34
    s->picture_number = get_bits(&s->gb, 8); /* picture timestamp */
 
35
 
 
36
    if (get_bits1(&s->gb) != 1) {
 
37
        av_log(s->avctx, AV_LOG_ERROR, "Bad marker\n");
 
38
        return -1;      /* marker */
 
39
    }
 
40
    if (get_bits1(&s->gb) != 0) {
 
41
        av_log(s->avctx, AV_LOG_ERROR, "Bad H263 id\n");
 
42
        return -1;      /* h263 id */
 
43
    }
 
44
    skip_bits1(&s->gb);         /* split screen off */
 
45
    skip_bits1(&s->gb);         /* camera  off */
 
46
    skip_bits1(&s->gb);         /* freeze picture release off */
 
47
 
 
48
    format = get_bits(&s->gb, 3);
 
49
    if (format != 7) {
 
50
        av_log(s->avctx, AV_LOG_ERROR, "Intel H263 free format not supported\n");
 
51
        return -1;
 
52
    }
 
53
    s->h263_plus = 0;
 
54
 
 
55
    s->pict_type = FF_I_TYPE + get_bits1(&s->gb);
 
56
 
 
57
    s->unrestricted_mv = get_bits1(&s->gb);
 
58
    s->h263_long_vectors = s->unrestricted_mv;
 
59
 
 
60
    if (get_bits1(&s->gb) != 0) {
 
61
        av_log(s->avctx, AV_LOG_ERROR, "SAC not supported\n");
 
62
        return -1;      /* SAC: off */
 
63
    }
 
64
    s->obmc= get_bits1(&s->gb);
 
65
    s->pb_frame = get_bits1(&s->gb);
 
66
 
 
67
    if(format == 7){
 
68
        format = get_bits(&s->gb, 3);
 
69
        if(format == 0 || format == 7){
 
70
            av_log(s->avctx, AV_LOG_ERROR, "Wrong Intel H263 format\n");
 
71
            return -1;
 
72
        }
 
73
        if(get_bits(&s->gb, 2))
 
74
            av_log(s->avctx, AV_LOG_ERROR, "Bad value for reserved field\n");
 
75
        s->loop_filter = get_bits1(&s->gb);
 
76
        if(get_bits1(&s->gb))
 
77
            av_log(s->avctx, AV_LOG_ERROR, "Bad value for reserved field\n");
 
78
        if(get_bits1(&s->gb))
 
79
            s->pb_frame = 2;
 
80
        if(get_bits(&s->gb, 5))
 
81
            av_log(s->avctx, AV_LOG_ERROR, "Bad value for reserved field\n");
 
82
        if(get_bits(&s->gb, 5) != 1)
 
83
            av_log(s->avctx, AV_LOG_ERROR, "Invalid marker\n");
 
84
    }
 
85
    if(format == 6){
 
86
        int ar = get_bits(&s->gb, 4);
 
87
        skip_bits(&s->gb, 9); // display width
 
88
        skip_bits1(&s->gb);
 
89
        skip_bits(&s->gb, 9); // display height
 
90
        if(ar == 15){
 
91
            skip_bits(&s->gb, 8); // aspect ratio - width
 
92
            skip_bits(&s->gb, 8); // aspect ratio - height
 
93
        }
 
94
    }
 
95
 
 
96
    s->chroma_qscale= s->qscale = get_bits(&s->gb, 5);
 
97
    skip_bits1(&s->gb); /* Continuous Presence Multipoint mode: off */
 
98
 
 
99
    if(s->pb_frame){
 
100
        skip_bits(&s->gb, 3); //temporal reference for B-frame
 
101
        skip_bits(&s->gb, 2); //dbquant
 
102
    }
 
103
 
 
104
    /* PEI */
 
105
    while (get_bits1(&s->gb) != 0) {
 
106
        skip_bits(&s->gb, 8);
 
107
    }
 
108
    s->f_code = 1;
 
109
 
 
110
    s->y_dc_scale_table=
 
111
    s->c_dc_scale_table= ff_mpeg1_dc_scale_table;
 
112
 
 
113
    ff_h263_show_pict_info(s);
 
114
 
 
115
    return 0;
 
116
}
 
117
 
 
118
AVCodec h263i_decoder = {
 
119
    "h263i",
 
120
    AVMEDIA_TYPE_VIDEO,
 
121
    CODEC_ID_H263I,
 
122
    sizeof(MpegEncContext),
 
123
    ff_h263_decode_init,
 
124
    NULL,
 
125
    ff_h263_decode_end,
 
126
    ff_h263_decode_frame,
 
127
    CODEC_CAP_DRAW_HORIZ_BAND | CODEC_CAP_DR1,
 
128
    .long_name = NULL_IF_CONFIG_SMALL("Intel H.263"),
 
129
    .pix_fmts= ff_pixfmt_list_420,
 
130
};
 
131