]> git.sesse.net Git - ffmpeg/blobdiff - libavcodec/rv10.c
3 lines while -> 1 line for loop
[ffmpeg] / libavcodec / rv10.c
index e35b2250dc00288178e72e955a613c1e5512050c..daec2b85bc91989973c55b8118c1c567516d0464 100644 (file)
@@ -15,7 +15,7 @@
  *
  * You should have received a copy of the GNU Lesser General Public
  * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
 /**
@@ -236,31 +236,31 @@ void rv10_encode_picture_header(MpegEncContext *s, int picture_number)
 
     align_put_bits(&s->pb);
 
-    put_bits(&s->pb, 1, 1);    /* marker */
+    put_bits(&s->pb, 1, 1);     /* marker */
 
     put_bits(&s->pb, 1, (s->pict_type == P_TYPE));
 
-    put_bits(&s->pb, 1, 0);    /* not PB frame */
+    put_bits(&s->pb, 1, 0);     /* not PB frame */
 
     put_bits(&s->pb, 5, s->qscale);
 
     if (s->pict_type == I_TYPE) {
-       /* specific MPEG like DC coding not used */
+        /* specific MPEG like DC coding not used */
     }
     /* if multiple packets per frame are sent, the position at which
        to display the macro blocks is coded here */
     if(!full_frame){
-        put_bits(&s->pb, 6, 0);        /* mb_x */
-        put_bits(&s->pb, 6, 0);        /* mb_y */
+        put_bits(&s->pb, 6, 0); /* mb_x */
+        put_bits(&s->pb, 6, 0); /* mb_y */
         put_bits(&s->pb, 12, s->mb_width * s->mb_height);
     }
 
-    put_bits(&s->pb, 3, 0);    /* ignored */
+    put_bits(&s->pb, 3, 0);     /* ignored */
 }
 
 void rv20_encode_picture_header(MpegEncContext *s, int picture_number){
     put_bits(&s->pb, 2, s->pict_type); //I 0 vs. 1 ?
-    put_bits(&s->pb, 1, 0);    /* unknown bit */
+    put_bits(&s->pb, 1, 0);     /* unknown bit */
     put_bits(&s->pb, 5, s->qscale);
 
     put_bits(&s->pb, 8, picture_number&0xFF); //FIXME wrong, but correct is not known
@@ -321,7 +321,7 @@ static int rv10_decode_picture_header(MpegEncContext *s)
     pb_frame = get_bits(&s->gb, 1);
 
 #ifdef DEBUG
-    printf("pict_type=%d pb_frame=%d\n", s->pict_type, pb_frame);
+    av_log(s->avctx, AV_LOG_DEBUG, "pict_type=%d pb_frame=%d\n", s->pict_type, pb_frame);
 #endif
 
     if (pb_frame){
@@ -342,7 +342,7 @@ static int rv10_decode_picture_header(MpegEncContext *s)
             s->last_dc[1] = get_bits(&s->gb, 8);
             s->last_dc[2] = get_bits(&s->gb, 8);
 #ifdef DEBUG
-            printf("DC:%d %d %d\n",
+            av_log(s->avctx, AV_LOG_DEBUG, "DC:%d %d %d\n",
                    s->last_dc[0],
                    s->last_dc[1],
                    s->last_dc[2]);
@@ -354,15 +354,15 @@ static int rv10_decode_picture_header(MpegEncContext *s)
 
     mb_xy= s->mb_x + s->mb_y*s->mb_width;
     if(show_bits(&s->gb, 12)==0 || (mb_xy && mb_xy < s->mb_num)){
-        s->mb_x = get_bits(&s->gb, 6); /* mb_x */
-        s->mb_y = get_bits(&s->gb, 6); /* mb_y */
+        s->mb_x = get_bits(&s->gb, 6); /* mb_x */
+        s->mb_y = get_bits(&s->gb, 6); /* mb_y */
         mb_count = get_bits(&s->gb, 12);
     } else {
         s->mb_x = 0;
         s->mb_y = 0;
         mb_count = s->mb_width * s->mb_height;
     }
-    unk= get_bits(&s->gb, 3);  /* ignored */
+    unk= get_bits(&s->gb, 3);   /* ignored */
 //printf("%d\n", unk);
     s->f_code = 1;
     s->unrestricted_mv = 1;
@@ -631,7 +631,7 @@ static int rv10_decode_packet(AVCodecContext *avctx,
     }
 
 #ifdef DEBUG
-    printf("qscale=%d\n", s->qscale);
+    av_log(avctx, AV_LOG_DEBUG, "qscale=%d\n", s->qscale);
 #endif
 
     /* default quantization values */
@@ -639,9 +639,9 @@ static int rv10_decode_packet(AVCodecContext *avctx,
         if(s->mb_y==0) s->first_slice_line=1;
     }else{
         s->first_slice_line=1;
-        s->resync_mb_x= s->mb_x;
-        s->resync_mb_y= s->mb_y;
     }
+    s->resync_mb_x= s->mb_x;
+    s->resync_mb_y= s->mb_y;
     if(s->h263_aic){
         s->y_dc_scale_table=
         s->c_dc_scale_table= ff_aic_dc_scale_table;
@@ -672,7 +672,7 @@ static int rv10_decode_packet(AVCodecContext *avctx,
         int ret;
         ff_update_block_index(s);
 #ifdef DEBUG
-        printf("**mb x=%d y=%d\n", s->mb_x, s->mb_y);
+        av_log(avctx, AV_LOG_DEBUG, "**mb x=%d y=%d\n", s->mb_x, s->mb_y);
 #endif
 
         s->mv_dir = MV_DIR_FORWARD;
@@ -713,7 +713,7 @@ static int rv10_decode_frame(AVCodecContext *avctx,
     AVFrame *pict = data;
 
 #ifdef DEBUG
-    printf("*****frame %d size=%d\n", avctx->frame_number, buf_size);
+    av_log(avctx, AV_LOG_DEBUG, "*****frame %d size=%d\n", avctx->frame_number, buf_size);
 #endif
 
     /* no supplementary picture */
@@ -737,19 +737,20 @@ static int rv10_decode_frame(AVCodecContext *avctx,
         rv10_decode_packet(avctx, buf, buf_size);
     }
 
-    if(s->mb_y>=s->mb_height){
+    if(s->current_picture_ptr != NULL && s->mb_y>=s->mb_height){
         ff_er_frame_end(s);
         MPV_frame_end(s);
 
-        if(s->pict_type==B_TYPE || s->low_delay){
-            *pict= *(AVFrame*)&s->current_picture;
-            ff_print_debug_info(s, pict);
-        } else {
-            *pict= *(AVFrame*)&s->last_picture;
-            ff_print_debug_info(s, pict);
+        if (s->pict_type == B_TYPE || s->low_delay) {
+            *pict= *(AVFrame*)s->current_picture_ptr;
+        } else if (s->last_picture_ptr != NULL) {
+            *pict= *(AVFrame*)s->last_picture_ptr;
         }
-        if(s->last_picture_ptr || s->low_delay)
+
+        if(s->last_picture_ptr || s->low_delay){
             *data_size = sizeof(AVFrame);
+            ff_print_debug_info(s, pict);
+        }
         s->current_picture_ptr= NULL; //so we can detect if frame_end wasnt called (find some nicer solution...)
     }