Mercurial > libavcodec.hg
comparison libschroedinger.c @ 10061:09f2db2d7c90 libavcodec
Fix bug caused by difference in stride and picture width.
When a frame is allocated using libschroedinger routines, the frame data size
does not match the actual frame size if the width is not a multiple of 16. So
we cannot do a straightforward memcpy of the frame returned by libschroedinger
into the FFmpeg picture as the stride differs from the width.
Fix this bug by allocating for the libschroedinger frame with the dimensions
in AVCodecContext within libavcodec and passing the frame to libschroedinger.
patch by Anuradha Suraparaju, anuradha rd.bbc.co uk
| author | diego |
|---|---|
| date | Sat, 15 Aug 2009 11:59:53 +0000 |
| parents | 965220ebc611 |
| children | 7dd2a45249a9 |
comparison
equal
deleted
inserted
replaced
| 10060:965220ebc611 | 10061:09f2db2d7c90 |
|---|---|
| 75 return 0; | 75 return 0; |
| 76 } | 76 } |
| 77 } | 77 } |
| 78 return -1; | 78 return -1; |
| 79 } | 79 } |
| 80 | |
| 81 static void FreeSchroFrame(SchroFrame *frame, void *priv) | |
| 82 { | |
| 83 AVPicture *p_pic = priv; | |
| 84 | |
| 85 if (!p_pic) | |
| 86 return; | |
| 87 | |
| 88 avpicture_free(p_pic); | |
| 89 av_freep(&p_pic); | |
| 90 } | |
| 91 | |
| 92 SchroFrame *ff_create_schro_frame(AVCodecContext *avccontext, | |
| 93 SchroFrameFormat schro_frame_fmt) | |
| 94 { | |
| 95 AVPicture *p_pic; | |
| 96 SchroFrame *p_frame; | |
| 97 int y_width, uv_width; | |
| 98 int y_height, uv_height; | |
| 99 int i; | |
| 100 | |
| 101 y_width = avccontext->width; | |
| 102 y_height = avccontext->height; | |
| 103 uv_width = y_width >> (SCHRO_FRAME_FORMAT_H_SHIFT(schro_frame_fmt)); | |
| 104 uv_height = y_height >> (SCHRO_FRAME_FORMAT_V_SHIFT(schro_frame_fmt)); | |
| 105 | |
| 106 p_pic = av_mallocz(sizeof(AVPicture)); | |
| 107 avpicture_alloc(p_pic, avccontext->pix_fmt, y_width, y_height); | |
| 108 | |
| 109 p_frame = schro_frame_new(); | |
| 110 p_frame->format = schro_frame_fmt; | |
| 111 p_frame->width = y_width; | |
| 112 p_frame->height = y_height; | |
| 113 schro_frame_set_free_callback(p_frame, FreeSchroFrame, (void *)p_pic); | |
| 114 | |
| 115 for (i = 0; i < 3; ++i) { | |
| 116 p_frame->components[i].width = i ? uv_width : y_width; | |
| 117 p_frame->components[i].stride = p_pic->linesize[i]; | |
| 118 p_frame->components[i].height = i ? uv_height : y_height; | |
| 119 p_frame->components[i].length = | |
| 120 p_frame->components[i].stride * p_frame->components[i].height; | |
| 121 p_frame->components[i].data = p_pic->data[i]; | |
| 122 | |
| 123 if (i) { | |
| 124 p_frame->components[i].v_shift = | |
| 125 SCHRO_FRAME_FORMAT_V_SHIFT(p_frame->format); | |
| 126 p_frame->components[i].h_shift = | |
| 127 SCHRO_FRAME_FORMAT_H_SHIFT(p_frame->format); | |
| 128 } | |
| 129 } | |
| 130 | |
| 131 return p_frame; | |
| 132 } |
