comparison h264_parser.c @ 8999:f701dab6a62d libavcodec

Set context variable picture_structure in H264 parser. Patch by Ivan Schreter, schreter gmx net
author cehoyos
date Sat, 21 Feb 2009 20:03:05 +0000
parents 9339bf262eb5
children 78afc2990d00
comparison
equal deleted inserted replaced
8998:9339bf262eb5 8999:f701dab6a62d
110 AVCodecContext *avctx, 110 AVCodecContext *avctx,
111 const uint8_t *buf, int buf_size) 111 const uint8_t *buf, int buf_size)
112 { 112 {
113 H264Context *h = s->priv_data; 113 H264Context *h = s->priv_data;
114 const uint8_t *buf_end = buf + buf_size; 114 const uint8_t *buf_end = buf + buf_size;
115 unsigned int pps_id;
115 unsigned int slice_type; 116 unsigned int slice_type;
116 int state; 117 int state;
117 const uint8_t *ptr; 118 const uint8_t *ptr;
118 119
119 /* set some sane default values */ 120 /* set some sane default values */
162 s->pict_type = golomb_to_pict_type[slice_type % 5]; 163 s->pict_type = golomb_to_pict_type[slice_type % 5];
163 if (h->sei_recovery_frame_cnt >= 0) { 164 if (h->sei_recovery_frame_cnt >= 0) {
164 /* key frame, since recovery_frame_cnt is set */ 165 /* key frame, since recovery_frame_cnt is set */
165 s->key_frame = 1; 166 s->key_frame = 1;
166 } 167 }
168 pps_id= get_ue_golomb(&h->s.gb);
169 if(pps_id>=MAX_PPS_COUNT) {
170 av_log(h->s.avctx, AV_LOG_ERROR, "pps_id out of range\n");
171 return -1;
172 }
173 if(!h->pps_buffers[pps_id]) {
174 av_log(h->s.avctx, AV_LOG_ERROR, "non-existing PPS referenced\n");
175 return -1;
176 }
177 h->pps= *h->pps_buffers[pps_id];
178 if(!h->sps_buffers[h->pps.sps_id]) {
179 av_log(h->s.avctx, AV_LOG_ERROR, "non-existing SPS referenced\n");
180 return -1;
181 }
182 h->sps = *h->sps_buffers[h->pps.sps_id];
183 h->frame_num = get_bits(&h->s.gb, h->sps.log2_max_frame_num);
184
185 if(h->sps.frame_mbs_only_flag){
186 h->s.picture_structure= PICT_FRAME;
187 }else{
188 if(get_bits1(&h->s.gb)) { //field_pic_flag
189 h->s.picture_structure= PICT_TOP_FIELD + get_bits1(&h->s.gb); //bottom_field_flag
190 } else {
191 h->s.picture_structure= PICT_FRAME;
192 }
193 }
194
167 return 0; /* no need to evaluate the rest */ 195 return 0; /* no need to evaluate the rest */
168 } 196 }
169 buf += consumed; 197 buf += consumed;
170 } 198 }
171 /* didn't find a picture! */ 199 /* didn't find a picture! */