]> git.sesse.net Git - ffmpeg/blobdiff - libavcodec/qtrleenc.c
avcodec/put_bits: Add functions for amount of bytes written/left
[ffmpeg] / libavcodec / qtrleenc.c
index cdd864bf820953cf22e6b389583ee9d95c0829a7..8b0edf7b3d8bb6189934916ce1be261d85ebfe0e 100644 (file)
@@ -259,9 +259,10 @@ static void qtrle_encode_line(QtrleEncContext *s, const AVFrame *p, int line, ui
         /* These bulk costs increase every iteration */
         lowest_bulk_cost += s->pixel_size;
         sec_lowest_bulk_cost += s->pixel_size;
-
-        this_line -= s->pixel_size;
-        prev_line -= s->pixel_size;
+        if (this_line >= p->data[0] + s->pixel_size)
+            this_line -= s->pixel_size;
+        if (prev_line >= s->previous_frame->data[0] + s->pixel_size)
+            prev_line -= s->pixel_size;
     }
 
     /* Good! Now we have the best sequence for this line, let's output it. */
@@ -412,4 +413,5 @@ AVCodec ff_qtrle_encoder = {
     .pix_fmts       = (const enum AVPixelFormat[]){
         AV_PIX_FMT_RGB24, AV_PIX_FMT_RGB555BE, AV_PIX_FMT_ARGB, AV_PIX_FMT_GRAY8, AV_PIX_FMT_NONE
     },
+    .caps_internal  = FF_CODEC_CAP_INIT_CLEANUP,
 };