[Ffmpeg-cvslog] CVS: ffmpeg/libavcodec avcodec.h, 1.456, 1.457 imgconvert.c, 1.61, 1.62

Baptiste Coudurier CVS bcoudurier
Fri Mar 10 14:55:51 CET 2006


Update of /cvsroot/ffmpeg/ffmpeg/libavcodec
In directory mail:/var2/tmp/cvs-serv1823/libavcodec

Modified Files:
	avcodec.h imgconvert.c 
Log Message:
Fix cropping, depending on enc pix fmt

Index: avcodec.h
===================================================================
RCS file: /cvsroot/ffmpeg/ffmpeg/libavcodec/avcodec.h,v
retrieving revision 1.456
retrieving revision 1.457
diff -u -d -r1.456 -r1.457
--- avcodec.h	21 Feb 2006 22:05:13 -0000	1.456
+++ avcodec.h	10 Mar 2006 13:55:48 -0000	1.457
@@ -2555,6 +2555,9 @@
 void img_copy(AVPicture *dst, const AVPicture *src,
               int pix_fmt, int width, int height);
 
+int img_crop(AVPicture *dst, const AVPicture *src,
+             int pix_fmt, int top_band, int left_band);
+
 /* av_log API */
 
 #include <stdarg.h>

Index: imgconvert.c
===================================================================
RCS file: /cvsroot/ffmpeg/ffmpeg/libavcodec/imgconvert.c,v
retrieving revision 1.61
retrieving revision 1.62
diff -u -d -r1.61 -r1.62
--- imgconvert.c	12 Jan 2006 22:43:15 -0000	1.61
+++ imgconvert.c	10 Mar 2006 13:55:48 -0000	1.62
@@ -1951,6 +1951,31 @@
         ps->pixel_type == FF_PIXEL_PLANAR;
 }
 
+/**
+ * Crop image top and left side
+ */
+int img_crop(AVPicture *dst, const AVPicture *src,
+              int pix_fmt, int top_band, int left_band)
+{
+    int y_shift;
+    int x_shift;
+
+    if (pix_fmt < 0 || pix_fmt >= PIX_FMT_NB || !is_yuv_planar(&pix_fmt_info[pix_fmt]))
+        return -1;
+
+    y_shift = pix_fmt_info[pix_fmt].y_chroma_shift;
+    x_shift = pix_fmt_info[pix_fmt].x_chroma_shift;
+
+    dst->data[0] = src->data[0] + (top_band * src->linesize[0]) + left_band;
+    dst->data[1] = src->data[1] + ((top_band >> y_shift) * src->linesize[1]) + (left_band >> x_shift);
+    dst->data[2] = src->data[2] + ((top_band >> y_shift) * src->linesize[2]) + (left_band >> x_shift);
+
+    dst->linesize[0] = src->linesize[0];
+    dst->linesize[1] = src->linesize[1];
+    dst->linesize[2] = src->linesize[2];
+    return 0;
+}
+
 /* XXX: always use linesize. Return -1 if not supported */
 int img_convert(AVPicture *dst, int dst_pix_fmt,
                 const AVPicture *src, int src_pix_fmt,





More information about the ffmpeg-cvslog mailing list