Loading media/libstagefright/codecs/on2/dec/SoftVPX.cpp +32 −32 Original line number Original line Diff line number Diff line Loading @@ -23,9 +23,6 @@ #include <media/stagefright/foundation/ADebug.h> #include <media/stagefright/foundation/ADebug.h> #include <media/stagefright/MediaDefs.h> #include <media/stagefright/MediaDefs.h> #include "vpx/vpx_decoder.h" #include "vpx/vpx_codec.h" #include "vpx/vp8dx.h" namespace android { namespace android { Loading @@ -41,7 +38,8 @@ SoftVPX::SoftVPX( NULL /* profileLevels */, 0 /* numProfileLevels */, NULL /* profileLevels */, 0 /* numProfileLevels */, 320 /* width */, 240 /* height */, callbacks, appData, component), 320 /* width */, 240 /* height */, callbacks, appData, component), mMode(codingType == OMX_VIDEO_CodingVP8 ? MODE_VP8 : MODE_VP9), mMode(codingType == OMX_VIDEO_CodingVP8 ? MODE_VP8 : MODE_VP9), mCtx(NULL) { mCtx(NULL), mImg(NULL) { initPorts(kNumBuffers, 768 * 1024 /* inputBufferSize */, initPorts(kNumBuffers, 768 * 1024 /* inputBufferSize */, kNumBuffers, kNumBuffers, codingType == OMX_VIDEO_CodingVP8 ? MEDIA_MIMETYPE_VIDEO_VP8 : MEDIA_MIMETYPE_VIDEO_VP9); codingType == OMX_VIDEO_CodingVP8 ? MEDIA_MIMETYPE_VIDEO_VP8 : MEDIA_MIMETYPE_VIDEO_VP9); Loading Loading @@ -118,6 +116,7 @@ void SoftVPX::onQueueFilled(OMX_U32 /* portIndex */) { } } } } if (mImg == NULL) { if (vpx_codec_decode( if (vpx_codec_decode( (vpx_codec_ctx_t *)mCtx, (vpx_codec_ctx_t *)mCtx, inHeader->pBuffer + inHeader->nOffset, inHeader->pBuffer + inHeader->nOffset, Loading @@ -129,15 +128,15 @@ void SoftVPX::onQueueFilled(OMX_U32 /* portIndex */) { notify(OMX_EventError, OMX_ErrorUndefined, 0, NULL); notify(OMX_EventError, OMX_ErrorUndefined, 0, NULL); return; return; } } vpx_codec_iter_t iter = NULL; vpx_codec_iter_t iter = NULL; vpx_image_t *img = vpx_codec_get_frame((vpx_codec_ctx_t *)mCtx, &iter); mImg = vpx_codec_get_frame((vpx_codec_ctx_t *)mCtx, &iter); } if (img != NULL) { if (mImg != NULL) { CHECK_EQ(img->fmt, IMG_FMT_I420); CHECK_EQ(mImg->fmt, IMG_FMT_I420); uint32_t width = img->d_w; uint32_t width = mImg->d_w; uint32_t height = img->d_h; uint32_t height = mImg->d_h; if (width != mWidth || height != mHeight) { if (width != mWidth || height != mHeight) { mWidth = width; mWidth = width; Loading Loading @@ -171,34 +170,35 @@ void SoftVPX::onQueueFilled(OMX_U32 /* portIndex */) { uint32_t buffer_stride = mIsAdaptive ? mAdaptiveMaxWidth : mWidth; uint32_t buffer_stride = mIsAdaptive ? mAdaptiveMaxWidth : mWidth; uint32_t buffer_height = mIsAdaptive ? mAdaptiveMaxHeight : mHeight; uint32_t buffer_height = mIsAdaptive ? mAdaptiveMaxHeight : mHeight; const uint8_t *srcLine = (const uint8_t *)img->planes[PLANE_Y]; const uint8_t *srcLine = (const uint8_t *)mImg->planes[PLANE_Y]; uint8_t *dst = outHeader->pBuffer; uint8_t *dst = outHeader->pBuffer; for (size_t i = 0; i < buffer_height; ++i) { for (size_t i = 0; i < buffer_height; ++i) { if (i < img->d_h) { if (i < mImg->d_h) { memcpy(dst, srcLine, img->d_w); memcpy(dst, srcLine, mImg->d_w); srcLine += img->stride[PLANE_Y]; srcLine += mImg->stride[PLANE_Y]; } } dst += buffer_stride; dst += buffer_stride; } } srcLine = (const uint8_t *)img->planes[PLANE_U]; srcLine = (const uint8_t *)mImg->planes[PLANE_U]; for (size_t i = 0; i < buffer_height / 2; ++i) { for (size_t i = 0; i < buffer_height / 2; ++i) { if (i < img->d_h / 2) { if (i < mImg->d_h / 2) { memcpy(dst, srcLine, img->d_w / 2); memcpy(dst, srcLine, mImg->d_w / 2); srcLine += img->stride[PLANE_U]; srcLine += mImg->stride[PLANE_U]; } } dst += buffer_stride / 2; dst += buffer_stride / 2; } } srcLine = (const uint8_t *)img->planes[PLANE_V]; srcLine = (const uint8_t *)mImg->planes[PLANE_V]; for (size_t i = 0; i < buffer_height / 2; ++i) { for (size_t i = 0; i < buffer_height / 2; ++i) { if (i < img->d_h / 2) { if (i < mImg->d_h / 2) { memcpy(dst, srcLine, img->d_w / 2); memcpy(dst, srcLine, mImg->d_w / 2); srcLine += img->stride[PLANE_V]; srcLine += mImg->stride[PLANE_V]; } } dst += buffer_stride / 2; dst += buffer_stride / 2; } } mImg = NULL; outInfo->mOwnedByUs = false; outInfo->mOwnedByUs = false; outQueue.erase(outQueue.begin()); outQueue.erase(outQueue.begin()); outInfo = NULL; outInfo = NULL; Loading media/libstagefright/codecs/on2/dec/SoftVPX.h +6 −0 Original line number Original line Diff line number Diff line Loading @@ -20,6 +20,10 @@ #include "SoftVideoDecoderOMXComponent.h" #include "SoftVideoDecoderOMXComponent.h" #include "vpx/vpx_decoder.h" #include "vpx/vpx_codec.h" #include "vpx/vp8dx.h" namespace android { namespace android { struct SoftVPX : public SoftVideoDecoderOMXComponent { struct SoftVPX : public SoftVideoDecoderOMXComponent { Loading Loading @@ -47,6 +51,8 @@ private: void *mCtx; void *mCtx; vpx_image_t *mImg; status_t initDecoder(); status_t initDecoder(); DISALLOW_EVIL_CONSTRUCTORS(SoftVPX); DISALLOW_EVIL_CONSTRUCTORS(SoftVPX); Loading Loading
media/libstagefright/codecs/on2/dec/SoftVPX.cpp +32 −32 Original line number Original line Diff line number Diff line Loading @@ -23,9 +23,6 @@ #include <media/stagefright/foundation/ADebug.h> #include <media/stagefright/foundation/ADebug.h> #include <media/stagefright/MediaDefs.h> #include <media/stagefright/MediaDefs.h> #include "vpx/vpx_decoder.h" #include "vpx/vpx_codec.h" #include "vpx/vp8dx.h" namespace android { namespace android { Loading @@ -41,7 +38,8 @@ SoftVPX::SoftVPX( NULL /* profileLevels */, 0 /* numProfileLevels */, NULL /* profileLevels */, 0 /* numProfileLevels */, 320 /* width */, 240 /* height */, callbacks, appData, component), 320 /* width */, 240 /* height */, callbacks, appData, component), mMode(codingType == OMX_VIDEO_CodingVP8 ? MODE_VP8 : MODE_VP9), mMode(codingType == OMX_VIDEO_CodingVP8 ? MODE_VP8 : MODE_VP9), mCtx(NULL) { mCtx(NULL), mImg(NULL) { initPorts(kNumBuffers, 768 * 1024 /* inputBufferSize */, initPorts(kNumBuffers, 768 * 1024 /* inputBufferSize */, kNumBuffers, kNumBuffers, codingType == OMX_VIDEO_CodingVP8 ? MEDIA_MIMETYPE_VIDEO_VP8 : MEDIA_MIMETYPE_VIDEO_VP9); codingType == OMX_VIDEO_CodingVP8 ? MEDIA_MIMETYPE_VIDEO_VP8 : MEDIA_MIMETYPE_VIDEO_VP9); Loading Loading @@ -118,6 +116,7 @@ void SoftVPX::onQueueFilled(OMX_U32 /* portIndex */) { } } } } if (mImg == NULL) { if (vpx_codec_decode( if (vpx_codec_decode( (vpx_codec_ctx_t *)mCtx, (vpx_codec_ctx_t *)mCtx, inHeader->pBuffer + inHeader->nOffset, inHeader->pBuffer + inHeader->nOffset, Loading @@ -129,15 +128,15 @@ void SoftVPX::onQueueFilled(OMX_U32 /* portIndex */) { notify(OMX_EventError, OMX_ErrorUndefined, 0, NULL); notify(OMX_EventError, OMX_ErrorUndefined, 0, NULL); return; return; } } vpx_codec_iter_t iter = NULL; vpx_codec_iter_t iter = NULL; vpx_image_t *img = vpx_codec_get_frame((vpx_codec_ctx_t *)mCtx, &iter); mImg = vpx_codec_get_frame((vpx_codec_ctx_t *)mCtx, &iter); } if (img != NULL) { if (mImg != NULL) { CHECK_EQ(img->fmt, IMG_FMT_I420); CHECK_EQ(mImg->fmt, IMG_FMT_I420); uint32_t width = img->d_w; uint32_t width = mImg->d_w; uint32_t height = img->d_h; uint32_t height = mImg->d_h; if (width != mWidth || height != mHeight) { if (width != mWidth || height != mHeight) { mWidth = width; mWidth = width; Loading Loading @@ -171,34 +170,35 @@ void SoftVPX::onQueueFilled(OMX_U32 /* portIndex */) { uint32_t buffer_stride = mIsAdaptive ? mAdaptiveMaxWidth : mWidth; uint32_t buffer_stride = mIsAdaptive ? mAdaptiveMaxWidth : mWidth; uint32_t buffer_height = mIsAdaptive ? mAdaptiveMaxHeight : mHeight; uint32_t buffer_height = mIsAdaptive ? mAdaptiveMaxHeight : mHeight; const uint8_t *srcLine = (const uint8_t *)img->planes[PLANE_Y]; const uint8_t *srcLine = (const uint8_t *)mImg->planes[PLANE_Y]; uint8_t *dst = outHeader->pBuffer; uint8_t *dst = outHeader->pBuffer; for (size_t i = 0; i < buffer_height; ++i) { for (size_t i = 0; i < buffer_height; ++i) { if (i < img->d_h) { if (i < mImg->d_h) { memcpy(dst, srcLine, img->d_w); memcpy(dst, srcLine, mImg->d_w); srcLine += img->stride[PLANE_Y]; srcLine += mImg->stride[PLANE_Y]; } } dst += buffer_stride; dst += buffer_stride; } } srcLine = (const uint8_t *)img->planes[PLANE_U]; srcLine = (const uint8_t *)mImg->planes[PLANE_U]; for (size_t i = 0; i < buffer_height / 2; ++i) { for (size_t i = 0; i < buffer_height / 2; ++i) { if (i < img->d_h / 2) { if (i < mImg->d_h / 2) { memcpy(dst, srcLine, img->d_w / 2); memcpy(dst, srcLine, mImg->d_w / 2); srcLine += img->stride[PLANE_U]; srcLine += mImg->stride[PLANE_U]; } } dst += buffer_stride / 2; dst += buffer_stride / 2; } } srcLine = (const uint8_t *)img->planes[PLANE_V]; srcLine = (const uint8_t *)mImg->planes[PLANE_V]; for (size_t i = 0; i < buffer_height / 2; ++i) { for (size_t i = 0; i < buffer_height / 2; ++i) { if (i < img->d_h / 2) { if (i < mImg->d_h / 2) { memcpy(dst, srcLine, img->d_w / 2); memcpy(dst, srcLine, mImg->d_w / 2); srcLine += img->stride[PLANE_V]; srcLine += mImg->stride[PLANE_V]; } } dst += buffer_stride / 2; dst += buffer_stride / 2; } } mImg = NULL; outInfo->mOwnedByUs = false; outInfo->mOwnedByUs = false; outQueue.erase(outQueue.begin()); outQueue.erase(outQueue.begin()); outInfo = NULL; outInfo = NULL; Loading
media/libstagefright/codecs/on2/dec/SoftVPX.h +6 −0 Original line number Original line Diff line number Diff line Loading @@ -20,6 +20,10 @@ #include "SoftVideoDecoderOMXComponent.h" #include "SoftVideoDecoderOMXComponent.h" #include "vpx/vpx_decoder.h" #include "vpx/vpx_codec.h" #include "vpx/vp8dx.h" namespace android { namespace android { struct SoftVPX : public SoftVideoDecoderOMXComponent { struct SoftVPX : public SoftVideoDecoderOMXComponent { Loading Loading @@ -47,6 +51,8 @@ private: void *mCtx; void *mCtx; vpx_image_t *mImg; status_t initDecoder(); status_t initDecoder(); DISALLOW_EVIL_CONSTRUCTORS(SoftVPX); DISALLOW_EVIL_CONSTRUCTORS(SoftVPX); Loading