From 54ba2c99aafe86332393f2f47fb66fe53dd4e295 Mon Sep 17 00:00:00 2001 From: Joao Carreira Date: Thu, 19 Feb 2015 11:32:15 +0000 Subject: [PATCH] Add supported formats in LibAvHandle --- lib/LibAvContextHandle.cpp | 64 +++++++++++++++++++++++++++++++++----- lib/LibAvContextHandle.h | 12 ++++++- 2 files changed, 67 insertions(+), 9 deletions(-) diff --git a/lib/LibAvContextHandle.cpp b/lib/LibAvContextHandle.cpp index 09c117a..8f10c7c 100644 --- a/lib/LibAvContextHandle.cpp +++ b/lib/LibAvContextHandle.cpp @@ -31,6 +31,56 @@ namespace plaYUVer { +std::vector LibAvContextHandle::supportedReadFormatsExt() +{ + std::vector formatsExt; + formatsExt.push_back( "avi" ); + formatsExt.push_back( "mp4" ); + formatsExt.push_back( "wmv" ); + formatsExt.push_back( "pgm" ); + formatsExt.push_back( "png" ); + formatsExt.push_back( "bmp" ); + formatsExt.push_back( "jpg" ); + return formatsExt; +} + +std::vector LibAvContextHandle::supportedReadFormatsName() +{ + std::vector formatsName; + formatsName.push_back( "Audio video interleaved" ); + formatsName.push_back( "MPEG4" ); + formatsName.push_back( "Windows media video" ); + formatsName.push_back( "Portable Grayscale Map" ); + formatsName.push_back( "Portable Network Graphics" ); + formatsName.push_back( "Windows Bitmap" ); + formatsName.push_back( "Joint Photographic Experts Group" ); + return formatsName; +} + +std::vector LibAvContextHandle::supportedWriteFormatsExt() +{ + std::vector formatsExt; + return formatsExt; +} + +std::vector LibAvContextHandle::supportedWriteFormatsName() +{ + std::vector formatsName; + return formatsName; +} + +std::vector LibAvContextHandle::supportedSaveFormatsExt() +{ + std::vector formatsExt; + return formatsExt; +} + +std::vector LibAvContextHandle::supportedSaveFormatsName() +{ + std::vector formatsName; + return formatsName; +} + static int open_codec_context( int *stream_idx, AVFormatContext *fmt_ctx, enum AVMediaType type ) { int ret; @@ -108,7 +158,6 @@ Bool LibAvContextHandle::initAvFormat( const char* filename, UInt& width, UInt& av_dict_set( &format_opts, "video_size", aux_string, 0 ); } - Int ffmpeg_pel_format = g_PlaYUVerFramePelFormatsList[pixel_format].ffmpegPelFormat; if( ffmpeg_pel_format >= 0 ) { @@ -144,7 +193,7 @@ Bool LibAvContextHandle::initAvFormat( const char* filename, UInt& width, UInt& // } // video_dst_bufsize = ret; - m_uiFrameBufferSize = av_image_get_buffer_size( video_dec_ctx->pix_fmt, video_dec_ctx->width, video_dec_ctx->height, 1); + m_uiFrameBufferSize = av_image_get_buffer_size( video_dec_ctx->pix_fmt, video_dec_ctx->width, video_dec_ctx->height, 1 ); getMem1D( &m_pchFrameBuffer, m_uiFrameBufferSize ); } @@ -204,7 +253,7 @@ Bool LibAvContextHandle::initAvFormat( const char* filename, UInt& width, UInt& break; } } - if( pixel_format == PlaYUVerFrame::NO_FMT ) + if( pixel_format == PlaYUVerFrame::NO_FMT ) { closeAvFormat(); return false; @@ -260,14 +309,13 @@ Bool LibAvContextHandle::decodeAvFormat() if( got_frame ) { - av_image_copy_to_buffer( m_pchFrameBuffer, m_uiFrameBufferSize, - frame->data,frame->linesize, video_dec_ctx->pix_fmt, video_dec_ctx->width, - video_dec_ctx->height, 1); + av_image_copy_to_buffer( m_pchFrameBuffer, m_uiFrameBufferSize, frame->data, frame->linesize, video_dec_ctx->pix_fmt, video_dec_ctx->width, + video_dec_ctx->height, 1 ); /* copy decoded frame to destination buffer: * this is required since rawvideo expects non aligned data */ - // av_image_copy( video_dst_data, video_dst_linesize, ( const uint8_t ** )( frame->data ), frame->linesize, video_dec_ctx->pix_fmt, video_dec_ctx->width, - // video_dec_ctx->height ); + // av_image_copy( video_dst_data, video_dst_linesize, ( const uint8_t ** )( frame->data ), frame->linesize, video_dec_ctx->pix_fmt, video_dec_ctx->width, + // video_dec_ctx->height ); } } av_free_packet( &pkt ); diff --git a/lib/LibAvContextHandle.h b/lib/LibAvContextHandle.h index 225fb2a..1a2e977 100644 --- a/lib/LibAvContextHandle.h +++ b/lib/LibAvContextHandle.h @@ -26,6 +26,8 @@ #define __LIBAVCONTEXTHANDLE_H__ #include +#include +#include #ifndef __PRI64_PREFIX #define __PRI64_PREFIX "l" @@ -52,6 +54,14 @@ namespace plaYUVer class LibAvContextHandle { public: + + static std::vector supportedReadFormatsExt(); + static std::vector supportedReadFormatsName(); + static std::vector supportedWriteFormatsExt(); + static std::vector supportedWriteFormatsName(); + static std::vector supportedSaveFormatsExt(); + static std::vector supportedSaveFormatsName(); + LibAvContextHandle() : m_bHasStream( false ) { @@ -70,7 +80,7 @@ public: { return m_acCodecName; } - UInt getStreamDuration( ) + UInt getStreamDuration() { return m_uiSecs; }