diff options
author | Peter Schlaile <peter@schlaile.de> | 2008-01-20 21:55:56 +0300 |
---|---|---|
committer | Peter Schlaile <peter@schlaile.de> | 2008-01-20 21:55:56 +0300 |
commit | 053dca1fa954d29251dbe841d287305ec81f4d01 (patch) | |
tree | 1248335ae974cf009c6d55ed20d6987f9b1f81fd /source | |
parent | f41798987123a7c4fa3dde8e24d568be07f6e1a0 (diff) |
== Sequencer / FFMPEG ==
This fixes:
[#7989] Sequence editor preview and anim render output broken on Linux PPC
and also optimizes RGBA -> ABGR conversion function a little bit.
(Fixing also a crash, if there is no ibuf->rect available...)
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/imbuf/intern/anim.c | 118 | ||||
-rw-r--r-- | source/blender/imbuf/intern/imageprocess.c | 32 |
2 files changed, 110 insertions, 40 deletions
diff --git a/source/blender/imbuf/intern/anim.c b/source/blender/imbuf/intern/anim.c index e72d535815e..1700790c4fa 100644 --- a/source/blender/imbuf/intern/anim.c +++ b/source/blender/imbuf/intern/anim.c @@ -594,7 +594,7 @@ static int startffmpeg(struct anim * anim) { anim->pFrame = avcodec_alloc_frame(); anim->pFrameRGB = avcodec_alloc_frame(); - if (avpicture_get_size(PIX_FMT_RGBA32, anim->x, anim->y) + if (avpicture_get_size(PIX_FMT_BGR32, anim->x, anim->y) != anim->x * anim->y * 4) { fprintf (stderr, "ffmpeg has changed alloc scheme ... ARGHHH!\n"); @@ -617,7 +617,7 @@ static int startffmpeg(struct anim * anim) { anim->pCodecCtx->pix_fmt, anim->pCodecCtx->width, anim->pCodecCtx->height, - PIX_FMT_RGBA, + PIX_FMT_BGR32, SWS_FAST_BILINEAR | SWS_PRINT_INFO, NULL, NULL, NULL); @@ -637,7 +637,7 @@ static ImBuf * ffmpeg_fetchibuf(struct anim * anim, int position) { avpicture_fill((AVPicture *)anim->pFrameRGB, (unsigned char*) ibuf->rect, - PIX_FMT_RGBA32, anim->x, anim->y); + PIX_FMT_BGR32, anim->x, anim->y); if (position != anim->curposition + 1) { if (position > anim->curposition + 1 @@ -714,34 +714,98 @@ static ImBuf * ffmpeg_fetchibuf(struct anim * anim, int position) { } if(frameFinished && pos_found == 1) { - int * dstStride = anim->pFrameRGB->linesize; - uint8_t** dst = anim->pFrameRGB->data; - int dstStride2[4]= { -dstStride[0], 0, 0, 0 }; - uint8_t* dst2[4]= { - dst[0] + (anim->y - 1)*dstStride[0], - 0, 0, 0 }; - int i; - unsigned char* r; - - sws_scale(anim->img_convert_ctx, - anim->pFrame->data, - anim->pFrame->linesize, - 0, - anim->pCodecCtx->height, - dst2, - dstStride2); + if (G.order == B_ENDIAN) { + int * dstStride + = anim->pFrameRGB->linesize; + uint8_t** dst = anim->pFrameRGB->data; + int dstStride2[4] + = { dstStride[0], 0, 0, 0 }; + uint8_t* dst2[4]= { + dst[0], 0, 0, 0 }; + int x,y,h,w; + unsigned char* bottom; + unsigned char* top; + + sws_scale(anim->img_convert_ctx, + anim->pFrame->data, + anim->pFrame->linesize, + 0, + anim->pCodecCtx->height, + dst2, + dstStride2); - /* workaround: sws_scale sets alpha = 0... */ + /* workaround: sws_scale + sets alpha = 0 and compensate + for altivec-bugs and flipy... */ - r = (unsigned char*) ibuf->rect; + bottom = (unsigned char*) ibuf->rect; + top = bottom + + ibuf->x * (ibuf->y-1) * 4; + + h = (ibuf->y + 1) / 2; + w = ibuf->x; + + for (y = 0; y < h; y++) { + unsigned char tmp[4]; + unsigned long * tmp_l = + (unsigned long*) tmp; + tmp[3] = 0xff; + + for (x = 0; x < w; x++) { + tmp[0] = bottom[3]; + tmp[1] = bottom[2]; + tmp[2] = bottom[1]; + + bottom[0] = top[3]; + bottom[1] = top[2]; + bottom[2] = top[1]; + bottom[3] = 0xff; + + *(unsigned long*) top + = *tmp_l; + + bottom +=4; + top += 4; + } + top -= 8 * w; + } - for (i = 0; i < ibuf->x * ibuf->y; i++) { - r[3] = 0xff; - r+=4; - } + av_free_packet(&packet); + break; + } else { + int * dstStride + = anim->pFrameRGB->linesize; + uint8_t** dst = anim->pFrameRGB->data; + int dstStride2[4] + = { -dstStride[0], 0, 0, 0 }; + uint8_t* dst2[4]= { + dst[0] + + (anim->y - 1)*dstStride[0], + 0, 0, 0 }; + int i; + unsigned char* r; + + sws_scale(anim->img_convert_ctx, + anim->pFrame->data, + anim->pFrame->linesize, + 0, + anim->pCodecCtx->height, + dst2, + dstStride2); + + /* workaround: sws_scale + sets alpha = 0... */ + + r = (unsigned char*) ibuf->rect; - av_free_packet(&packet); - break; + for (i = 0; i < ibuf->x * ibuf->y;i++){ + r[3] = 0xff; + r+=4; + } + + av_free_packet(&packet); + break; + } } } diff --git a/source/blender/imbuf/intern/imageprocess.c b/source/blender/imbuf/intern/imageprocess.c index 54e0ec94672..aa09fc3ee38 100644 --- a/source/blender/imbuf/intern/imageprocess.c +++ b/source/blender/imbuf/intern/imageprocess.c @@ -51,22 +51,28 @@ I stole it from util.h in the plugins api */ /* Only this one is used liberally here, and in imbuf */ void IMB_convert_rgba_to_abgr(struct ImBuf *ibuf) { - int size, do_float=0; + int size; unsigned char rt, *cp = (unsigned char *)ibuf->rect; float rtf, *cpf = ibuf->rect_float; - - if (ibuf->rect_float) do_float = 1; - size = ibuf->x * ibuf->y; - while(size-- > 0) { - rt= cp[0]; - cp[0]= cp[3]; - cp[3]= rt; - rt= cp[1]; - cp[1]= cp[2]; - cp[2]= rt; - cp+= 4; - if (do_float) { + if (ibuf->rect) { + size = ibuf->x * ibuf->y; + + while(size-- > 0) { + rt= cp[0]; + cp[0]= cp[3]; + cp[3]= rt; + rt= cp[1]; + cp[1]= cp[2]; + cp[2]= rt; + cp+= 4; + } + } + + if (ibuf->rect_float) { + size = ibuf->x * ibuf->y; + + while(size-- > 0) { rtf= cpf[0]; cpf[0]= cpf[3]; cpf[3]= rtf; |