comparison h264.c @ 5770:a1a947d67948 libavcodec

Further modularize short reference list management for upcoming PAFF implementation. patch by Jeff Downs, heydowns a borg d com original thread: Subject: [FFmpeg-devel] [PATCH] Implement PAFF in H.264 Date: 18/09/07 20:30
author andoma
date Thu, 04 Oct 2007 06:38:58 +0000
parents 59049863494c
children 5290a3850c03
comparison
equal deleted inserted replaced
5769:59049863494c 5770:a1a947d67948
3159 if(h->s.current_picture_ptr) 3159 if(h->s.current_picture_ptr)
3160 h->s.current_picture_ptr->reference= 0; 3160 h->s.current_picture_ptr->reference= 0;
3161 } 3161 }
3162 3162
3163 /** 3163 /**
3164 * Find a Picture in the short term reference list by frame number.
3165 * @param frame_num frame number to search for
3166 * @param idx the index into h->short_ref where returned picture is found
3167 * undefined if no picture found.
3168 * @return pointer to the found picture, or NULL if no pic with the provided
3169 * frame number is found
3170 */
3171 static Picture * find_short(H264Context *h, int frame_num, int *idx){
3172 MpegEncContext * const s = &h->s;
3173 int i;
3174
3175 for(i=0; i<h->short_ref_count; i++){
3176 Picture *pic= h->short_ref[i];
3177 if(s->avctx->debug&FF_DEBUG_MMCO)
3178 av_log(h->s.avctx, AV_LOG_DEBUG, "%d %d %p\n", i, pic->frame_num, pic);
3179 if(pic->frame_num == frame_num) {
3180 *idx = i;
3181 return pic;
3182 }
3183 }
3184 return NULL;
3185 }
3186
3187 /**
3188 * Remove a picture from the short term reference list by its index in
3189 * that list. This does no checking on the provided index; it is assumed
3190 * to be valid. Other list entries are shifted down.
3191 * @param i index into h->short_ref of picture to remove.
3192 */
3193 static void remove_short_at_index(H264Context *h, int i){
3194 assert(i > 0 && i < h->short_ref_count);
3195 h->short_ref[i]= NULL;
3196 if (--h->short_ref_count)
3197 memmove(&h->short_ref[i], &h->short_ref[i+1], (h->short_ref_count - i)*sizeof(Picture*));
3198 }
3199
3200 /**
3164 * 3201 *
3165 * @return the removed picture or NULL if an error occurs 3202 * @return the removed picture or NULL if an error occurs
3166 */ 3203 */
3167 static Picture * remove_short(H264Context *h, int frame_num){ 3204 static Picture * remove_short(H264Context *h, int frame_num){
3168 MpegEncContext * const s = &h->s; 3205 MpegEncContext * const s = &h->s;
3206 Picture *pic;
3169 int i; 3207 int i;
3170 3208
3171 if(s->avctx->debug&FF_DEBUG_MMCO) 3209 if(s->avctx->debug&FF_DEBUG_MMCO)
3172 av_log(h->s.avctx, AV_LOG_DEBUG, "remove short %d count %d\n", frame_num, h->short_ref_count); 3210 av_log(h->s.avctx, AV_LOG_DEBUG, "remove short %d count %d\n", frame_num, h->short_ref_count);
3173 3211
3174 for(i=0; i<h->short_ref_count; i++){ 3212 pic = find_short(h, frame_num, &i);
3175 Picture *pic= h->short_ref[i]; 3213 if (pic)
3176 if(s->avctx->debug&FF_DEBUG_MMCO) 3214 remove_short_at_index(h, i);
3177 av_log(h->s.avctx, AV_LOG_DEBUG, "%d %d %p\n", i, pic->frame_num, pic); 3215
3178 if(pic->frame_num == frame_num){ 3216 return pic;
3179 h->short_ref[i]= NULL;
3180 if (--h->short_ref_count)
3181 memmove(&h->short_ref[i], &h->short_ref[i+1], (h->short_ref_count - i)*sizeof(Picture*));
3182 return pic;
3183 }
3184 }
3185 return NULL;
3186 } 3217 }
3187 3218
3188 /** 3219 /**
3189 * 3220 *
3190 * @return the removed picture or NULL if an error occurs 3221 * @return the removed picture or NULL if an error occurs