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
689689 case PIX_FMT_NV21:
690690 w2 = (width + (1 << pinfo->x_chroma_shift) - 1) >> pinfo->x_chroma_shift;
691691 picture->linesize[0] = width;
692− picture->linesize[1] = w2;
692+ picture->linesize[1] = 2 * w2;
693693 break;
694694 case PIX_FMT_RGB24:
695695 case PIX_FMT_BGR24:
@@ -789,12 +789,12 @@ int ff_fill_pointer(AVPicture *picture, uint8_t *ptr, enum PixelFormat pix_fmt, · 93 unmodified lines
789789 case PIX_FMT_NV12:
790790 case PIX_FMT_NV21:
791791 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;
793793 picture->data[0] = ptr;
794794 picture->data[1] = picture->data[0] + size;
795795 picture->data[2] = NULL;
796796 picture->data[3] = NULL;
797− return size + 2 * size2;
797+ return size + size2;
798798 case PIX_FMT_RGB24:
799799 case PIX_FMT_BGR24:
800800 case PIX_FMT_ARGB:
@@ -904,6 +904,8 @@ int avpicture_layout(const AVPicture* src, enum PixelFormat pix_fmt, int width, · 103 unmodified lines
904904 if (i == 1) {
905905 w = ((width >> pf->x_chroma_shift) * pf->depth + 7) / 8;
906906 h = height >> pf->y_chroma_shift;
907+ if (pix_fmt == PIX_FMT_NV12 || pix_fmt == PIX_FMT_NV21)
908+ w <<= 1;
907909 } else if (i == 3) {
908910 w = ow;
909911 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