aboutsummaryrefslogtreecommitdiffstats
path: root/libavcodec
diff options
context:
space:
mode:
authorJeff Downs <heydowns@borg.com>2007-10-04 06:38:58 +0000
committerAndreas Ă–man <andreas@lonelycoder.com>2007-10-04 06:38:58 +0000
commit47e112f8729290068ec88cc3b8402c4ca7ac99a5 (patch)
tree57629d1ae52337e23c2c489b6322203eb1e5df5f /libavcodec
parent5a7b254c75e7577ce5a8d4036e6fb7708180869a (diff)
downloadffmpeg-47e112f8729290068ec88cc3b8402c4ca7ac99a5.tar.gz
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 Originally committed as revision 10661 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavcodec')
-rw-r--r--libavcodec/h264.c51
1 files changed, 41 insertions, 10 deletions
diff --git a/libavcodec/h264.c b/libavcodec/h264.c
index 9a521c0763..95e76d57bc 100644
--- a/libavcodec/h264.c
+++ b/libavcodec/h264.c
@@ -3161,24 +3161,23 @@ static void flush_dpb(AVCodecContext *avctx){
}
/**
- *
- * @return the removed picture or NULL if an error occurs
+ * Find a Picture in the short term reference list by frame number.
+ * @param frame_num frame number to search for
+ * @param idx the index into h->short_ref where returned picture is found
+ * undefined if no picture found.
+ * @return pointer to the found picture, or NULL if no pic with the provided
+ * frame number is found
*/
-static Picture * remove_short(H264Context *h, int frame_num){
+static Picture * find_short(H264Context *h, int frame_num, int *idx){
MpegEncContext * const s = &h->s;
int i;
- if(s->avctx->debug&FF_DEBUG_MMCO)
- av_log(h->s.avctx, AV_LOG_DEBUG, "remove short %d count %d\n", frame_num, h->short_ref_count);
-
for(i=0; i<h->short_ref_count; i++){
Picture *pic= h->short_ref[i];
if(s->avctx->debug&FF_DEBUG_MMCO)
av_log(h->s.avctx, AV_LOG_DEBUG, "%d %d %p\n", i, pic->frame_num, pic);
- if(pic->frame_num == frame_num){
- h->short_ref[i]= NULL;
- if (--h->short_ref_count)
- memmove(&h->short_ref[i], &h->short_ref[i+1], (h->short_ref_count - i)*sizeof(Picture*));
+ if(pic->frame_num == frame_num) {
+ *idx = i;
return pic;
}
}
@@ -3186,6 +3185,38 @@ static Picture * remove_short(H264Context *h, int frame_num){
}
/**
+ * Remove a picture from the short term reference list by its index in
+ * that list. This does no checking on the provided index; it is assumed
+ * to be valid. Other list entries are shifted down.
+ * @param i index into h->short_ref of picture to remove.
+ */
+static void remove_short_at_index(H264Context *h, int i){
+ assert(i > 0 && i < h->short_ref_count);
+ h->short_ref[i]= NULL;
+ if (--h->short_ref_count)
+ memmove(&h->short_ref[i], &h->short_ref[i+1], (h->short_ref_count - i)*sizeof(Picture*));
+}
+
+/**
+ *
+ * @return the removed picture or NULL if an error occurs
+ */
+static Picture * remove_short(H264Context *h, int frame_num){
+ MpegEncContext * const s = &h->s;
+ Picture *pic;
+ int i;
+
+ if(s->avctx->debug&FF_DEBUG_MMCO)
+ av_log(h->s.avctx, AV_LOG_DEBUG, "remove short %d count %d\n", frame_num, h->short_ref_count);
+
+ pic = find_short(h, frame_num, &i);
+ if (pic)
+ remove_short_at_index(h, i);
+
+ return pic;
+}
+
+/**
*
* @return the removed picture or NULL if an error occurs
*/