History

Fix nv12/nv21 handling. linesize for plane 1 should account for both chroma planes instead of just doubling the height while computing plane sizes. Also adjust avpicture_layout() to copy the correct amount of data for plane 1.

Originally committed as revision 20610 to svn://svn.ffmpeg.org/ffmpeg/trunk

Ramiro Polla committed 16 years ago

Commit f2526201 parent 800841f1 file · +5 −3Browse files

Unified · Split

libavcodec/imgconvert.c+5−3
@@ -689,7 +689,7 @@ int ff_fill_linesize(AVPicture *picture, enum PixelFormat pix_fmt, int width) · 688 unmodified lines
689 case PIX_FMT_NV21:689 case PIX_FMT_NV21:
690 w2 = (width + (1 << pinfo->x_chroma_shift) - 1) >> pinfo->x_chroma_shift;690 w2 = (width + (1 << pinfo->x_chroma_shift) - 1) >> pinfo->x_chroma_shift;
691 picture->linesize[0] = width;691 picture->linesize[0] = width;
692 picture->linesize[1] = w2;692 picture->linesize[1] = 2 * w2;
693 break;693 break;
694 case PIX_FMT_RGB24:694 case PIX_FMT_RGB24:
695 case PIX_FMT_BGR24:695 case PIX_FMT_BGR24:
@@ -789,12 +789,12 @@ int ff_fill_pointer(AVPicture *picture, uint8_t *ptr, enum PixelFormat pix_fmt, · 93 unmodified lines
789 case PIX_FMT_NV12:789 case PIX_FMT_NV12:
790 case PIX_FMT_NV21:790 case PIX_FMT_NV21:
791 h2 = (height + (1 << pinfo->y_chroma_shift) - 1) >> pinfo->y_chroma_shift;791 h2 = (height + (1 << pinfo->y_chroma_shift) - 1) >> pinfo->y_chroma_shift;
792 size2 = picture->linesize[1] * h2 * 2;792 size2 = picture->linesize[1] * h2;
793 picture->data[0] = ptr;793 picture->data[0] = ptr;
794 picture->data[1] = picture->data[0] + size;794 picture->data[1] = picture->data[0] + size;
795 picture->data[2] = NULL;795 picture->data[2] = NULL;
796 picture->data[3] = NULL;796 picture->data[3] = NULL;
797 return size + 2 * size2;797 return size + size2;
798 case PIX_FMT_RGB24:798 case PIX_FMT_RGB24:
799 case PIX_FMT_BGR24:799 case PIX_FMT_BGR24:
800 case PIX_FMT_ARGB:800 case PIX_FMT_ARGB:
@@ -904,6 +904,8 @@ int avpicture_layout(const AVPicture* src, enum PixelFormat pix_fmt, int width, · 103 unmodified lines
904 if (i == 1) {904 if (i == 1) {
905 w = ((width >> pf->x_chroma_shift) * pf->depth + 7) / 8;905 w = ((width >> pf->x_chroma_shift) * pf->depth + 7) / 8;
906 h = height >> pf->y_chroma_shift;906 h = height >> pf->y_chroma_shift;
907 if (pix_fmt == PIX_FMT_NV12 || pix_fmt == PIX_FMT_NV21)
908 w <<= 1;
907 } else if (i == 3) {909 } else if (i == 3) {
908 w = ow;910 w = ow;
909 h = oh;911 h = oh;

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t