#include "mm_file_format_frame.h"
#define MILLION 1000000
-#ifdef MMFILE_FORMAT_DEBUG_DUMP
-static void __save_frame(int width, int height, unsigned char *frame, int size, int iFrame);
-void __save_frame(int width, int height, unsigned char *frame, int size, int iFrame)
+#ifdef MMFILE_FORMAT_DEBUG_DUMP
+static void __save_frame(int width, int height, unsigned char *frame, int size, int iFrame)
{
FILE *pFile;
- char szFilename[32] = {0,};
- int y = 0;
+ char szFilename[32] = {0, };
/* Open file */
- memset(szFilename, 0x00, sizeof(szFilename));
snprintf(szFilename, sizeof(szFilename), "frame%d.ppm", iFrame);
pFile = fopen(szFilename, "wb");
if (pFile == NULL)
}
#endif
-static int _mmf_mem_read(void *opaque, uint8_t *buf, int size);
-static int64_t _mmf_mem_seek(void *opaque, int64_t pos, int whence);
-
typedef struct {
unsigned char *ptr;
long long size;
int state;
} MMFmemIOHandle;
-static int _mmf_mem_open(MMFmemIOHandle **handle, const char *filename)
+static bool __mmf_mem_open(MMFmemIOHandle **handle, const char *filename)
{
MMFmemIOHandle *memHandle = NULL;
char **splitedString = NULL;
mm_file_retvm_if_fails(DEBUG, splitedString, MMFILE_UTIL_FAIL);
if (!splitedString[0] || !splitedString[1]) {
- debug_error(DEBUG, "invalid param\n");
- goto exception;
+ debug_error(DEBUG, "invalid param");
+ g_strfreev(splitedString);
+
+ return false;
}
memHandle = g_new0(MMFmemIOHandle, 1);
- memHandle->ptr = (unsigned char *)atoll(splitedString[0]); /*memory allocation address changed. memHandle->ptr = (unsigned char*)atoi(splitedString[0]); */
+ /*memory allocation address changed. memHandle->ptr = (unsigned char*)atoi(splitedString[0]); */
+ memHandle->ptr = (unsigned char *)atoll(splitedString[0]);
memHandle->size = atoi(splitedString[1]);
memHandle->offset = 0;
memHandle->state = 0;
g_strfreev(splitedString);
- return MMFILE_UTIL_SUCCESS;
-
-exception:
- g_strfreev(splitedString);
-
- return MMFILE_UTIL_FAIL;
+ return true;
}
-static int _mmf_mem_read(void *opaque, uint8_t *buf, int size)
+static int __mmf_mem_read(void *opaque, uint8_t *buf, int size)
{
MMFmemIOHandle *memHandle = NULL;
const unsigned char *c = NULL;
int len = 0;
- if (!opaque || !buf) {
- debug_error(DEBUG, "invalid para\n");
- return MMFILE_UTIL_FAIL;
- }
+ mm_file_retvm_if_fails(DEBUG, opaque, MMFILE_UTIL_FAIL);
+ mm_file_retvm_if_fails(DEBUG, buf, MMFILE_UTIL_FAIL);
memHandle = opaque;
- if (!memHandle->ptr) {
- debug_error(DEBUG, "invalid para\n");
- return MMFILE_UTIL_FAIL;
- }
-
- if (memHandle->offset >= memHandle->size) {
- /* for some file formats last file read */
- debug_error(DEBUG, "File Read is beyond the file Size\n");
- return MMFILE_UTIL_FAIL;
-
- }
+ mm_file_retvm_if_fails(DEBUG, memHandle->ptr, MMFILE_UTIL_FAIL);
+ mm_file_retvm_if_fails(DEBUG, memHandle->offset < memHandle->size, MMFILE_UTIL_FAIL);
c = memHandle->ptr + memHandle->offset;
if (memHandle->state != EOF) {
len = size;
- if (len + memHandle->offset > memHandle->size) {
+ if (len + memHandle->offset > memHandle->size)
len = memHandle->size - memHandle->offset;
- }
}
memcpy(buf, c, len);
memHandle->offset += len;
- if (memHandle->offset == memHandle->size) {
+ if (memHandle->offset == memHandle->size)
memHandle->state = EOF;
- }
return len;
}
-static int64_t _mmf_mem_seek(void *opaque, int64_t pos, int whence)
+static int64_t __mmf_mem_seek(void *opaque, int64_t pos, int whence)
{
MMFmemIOHandle *memHandle = NULL;
long long tmp_offset = 0;
- if (!opaque) {
- debug_error(DEBUG, "invalid para\n");
- return MMFILE_UTIL_FAIL;
- }
+ mm_file_retvm_if_fails(DEBUG, opaque, MMFILE_UTIL_FAIL);
memHandle = opaque;
}
/*check validation*/
- if (tmp_offset < 0 && tmp_offset > memHandle->size) {
- debug_error(DEBUG, "invalid file offset\n");
- return MMFILE_UTIL_FAIL;
- }
+ mm_file_retvm_if_fails(DEBUG, tmp_offset >= 0 && tmp_offset <= memHandle->size, MMFILE_UTIL_FAIL);
/*set */
memHandle->state = (tmp_offset >= memHandle->size) ? EOF : !EOF;
int (*Open)(MMFileFormatContext *fileContext);
int (*Valid)(MMFileIOHandle *pFileIO, const char *mmfileuri, int mp3FrameCnt);
} MMFileFunc[MM_FILE_FORMAT_NUM + 1];
-static int __get_fileformat(const char *urifilename, int *format)
+
+static bool __get_fileformat(const char *urifilename, int *format)
{
int index;
- int ret = 0;
MMFileIOHandle *fp = NULL;
- debug_error(DEBUG, "%s\n", urifilename);
+ debug_error(DEBUG, "%s", urifilename);
- ret = mmfile_open(&fp, urifilename, MMFILE_RDONLY);
-
- if (ret == MMFILE_UTIL_FAIL) {
- debug_error(DEBUG, "error: mmfile_open\n");
- mmfile_close(fp);
- return MMFILE_FORMAT_FAIL;
- }
+ mm_file_retvm_if_fails(DEBUG, mmfile_open(&fp, urifilename, MMFILE_RDONLY) == MMFILE_UTIL_SUCCESS, false);
for (index = 0; index < MM_FILE_FORMAT_NUM; index++) {
- debug_msg(RELEASE, "search index = [%d]\n", index);
+ debug_msg(RELEASE, "search index = [%d]", index);
switch (index) {
case MM_FILE_FORMAT_QT:
default: {
*format = MM_FILE_FORMAT_NUM;
- debug_error(DEBUG, "error: not supported or invaild format enum[%d]\n", index);
+ debug_error(DEBUG, "error: not supported or invaild format enum[%d]", index);
break;
}
}
}
if (index == MM_FILE_FORMAT_NUM) {
- debug_error(DEBUG, "Can't probe file type\n");
+ debug_error(DEBUG, "Can't probe file type");
}
*format = -1;
mmfile_close(fp);
- return MMFILE_FORMAT_FAIL;
+ return false;
FILE_FORMAT_SUCCESS:
mmfile_close(fp);
- return MMFILE_FORMAT_SUCCESS;
+ return true;
}
-static int __mmfile_get_first_video_stream(AVFormatContext *pFormatCtx, int *videoStream)
+static bool __mmfile_get_first_video_stream(AVFormatContext *pFormatCtx, int *videoStream)
{
unsigned int i = 0;
for (i = 0; i < pFormatCtx->nb_streams; i++) {
if (pFormatCtx->streams[i]->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) {
*videoStream = i;
- break;
+ return true;
}
}
- if (*videoStream == -1) {
- debug_error(DEBUG, "error : videoStream == -1");
- return MMFILE_FORMAT_FAIL;
- }
-
- return MMFILE_FORMAT_SUCCESS;
+ return false;
}
-static int __mmfile_open_video_codec(AVFormatContext *pFormatCtx, int videoStream, AVCodecContext **ppVideoCodecCtx)
+static bool __mmfile_open_video_codec(AVFormatContext *pFormatCtx, int videoStream, AVCodecContext **ppVideoCodecCtx)
{
AVCodecContext *pVideoCodecCtx = NULL;
AVCodecParameters *pVideoCodecPar = NULL;
/* Get a pointer to the codec context for the video stream */
pVideoCodecPar = pFormatCtx->streams[videoStream]->codecpar;
- if (!pVideoCodecPar) {
- debug_error(DEBUG, "invalid param\n");
- return MMFILE_FORMAT_FAIL;
- }
+ mm_file_retvm_if_fails(DEBUG, pVideoCodecPar, false);
/* Find the decoder for the video stream */
pVideoCodec = avcodec_find_decoder(pVideoCodecPar->codec_id);
- if (!pVideoCodec) {
- debug_error(DEBUG, "error : Unsupported codec");
- return MMFILE_FORMAT_FAIL;
- }
+ mm_file_retvm_if_fails(DEBUG, pVideoCodec, false);
pVideoCodecCtx = avcodec_alloc_context3(pVideoCodec);
- if (!pVideoCodecCtx) {
- debug_error(DEBUG, "error: pVideoCodecCtx == NULL\n");
- return MMFILE_FORMAT_FAIL;
- }
+ mm_file_retvm_if_fails(DEBUG, pVideoCodecCtx, false);
if (avcodec_parameters_to_context(pVideoCodecCtx, pVideoCodecPar) < 0) {
- debug_error(DEBUG, "error: avcodec_parameters_to_context\n");
- return MMFILE_FORMAT_FAIL;
+ debug_error(DEBUG, "error: avcodec_parameters_to_context");
+ return false;
}
- /*set workaround bug flag*/
- //pVideoCodecCtx->workaround_bugs = FF_BUG_AUTODETECT;
-
/* Open codec */
pVideoCodecCtx->thread_type = 0;
pVideoCodecCtx->thread_count = 0;
if (avcodec_open2(pVideoCodecCtx, pVideoCodec, NULL) < 0) {
debug_error(DEBUG, "error : avcodec_open failed");
- return MMFILE_FORMAT_FAIL;
+ return false;
}
*ppVideoCodecCtx = pVideoCodecCtx;
- return MMFILE_FORMAT_SUCCESS;
+ return true;
}
-static int __mmfile_seek_to_pos(AVFormatContext *pFormatCtx, int64_t pos, bool is_accurate)
+static bool __mmfile_seek_to_pos(AVFormatContext *pFormatCtx, int64_t pos, bool is_accurate)
{
- double duration = 0;
+ double duration = (double) pFormatCtx->duration / AV_TIME_BASE * MILLION;
- duration = (double) pFormatCtx->duration / AV_TIME_BASE;
-#if 0
- if (duration <= 0) {
- double tmpDuration = 0.0;
-
- if (pStream->codec->bit_rate > 0 && pFormatCtx->file_size > 0) {
- if (pStream->codec->bit_rate >= 8)
- tmpDuration = 0.9 * pFormatCtx->file_size / (pStream->codec->bit_rate / 8);
-
- if (tmpDuration > 0)
- duration = tmpDuration;
- }
- }
-#endif
- duration = duration * MILLION;
- if ((duration <= 0) || (duration <= pos)) {
- debug_error(DEBUG, "duration error duration[%f] pos[%"PRId64"]", duration, pos);
- return MMFILE_FORMAT_FAIL;
- }
+ mm_file_retvm_if_fails(DEBUG, duration > 0, false);
+ mm_file_retvm_if_fails(DEBUG, duration > pos, false);
if (is_accurate)
av_seek_frame(pFormatCtx, -1, pos, AVSEEK_FLAG_ANY);
else
av_seek_frame(pFormatCtx, -1, pos, AVSEEK_FLAG_BACKWARD);
- return MMFILE_FORMAT_SUCCESS;
+ return true;
}
-static bool __mmfile_find_proper_frame(AVFormatContext *pFormatCtx, int videoStream, AVCodecContext *pVideoCodecCtx, int64_t pos, bool is_accurate, AVFrame *pFrame)
+static bool __mmfile_find_proper_frame(AVFormatContext *pFormatCtx,
+ int videoStream,
+ AVCodecContext *pVideoCodecCtx,
+ int64_t pos,
+ bool is_accurate,
+ AVFrame *pFrame)
{
bool find = false;
AVPacket packet;
}
}
} else {
- debug_msg(RELEASE, "decode not completed.\n");
+ debug_msg(RELEASE, "decode not completed.");
}
- if (find) {
+ if (find)
break;
- }
}
/* Free the packet that was allocated by av_read_frame*/
return find;
}
-static int __mmfile_swscale_frame(AVCodecContext *pVideoCodecCtx, AVFrame *pFrame, int width, int height, unsigned char *frame, int size)
+static bool __mmfile_swscale_frame(AVCodecContext *pVideoCodecCtx,
+ AVFrame *pFrame,
+ int width,
+ int height,
+ unsigned char *frame,
+ int size)
{
- int ret = MMFILE_FORMAT_SUCCESS;
int av_err = 0;
uint8_t *dst_data[4];
int dst_linesize[4];
struct SwsContext *img_convert_ctx = NULL;
- av_err = av_image_fill_arrays(dst_data, dst_linesize, frame, AV_PIX_FMT_RGB24, width, height, 1);
- if (av_err < 0) {
- debug_error(DEBUG, "error: avpicture_fill fail. errcode = 0x%08X\n", ret);
- ret = MMFILE_FORMAT_FAIL;
- goto exception;
+ if (av_image_fill_arrays(dst_data, dst_linesize, frame, AV_PIX_FMT_RGB24, width, height, 1) < 0) {
+ debug_error(DEBUG, "error: avpicture_fill fail");
+ return false;
}
img_convert_ctx = sws_getContext(width, height, pVideoCodecCtx->pix_fmt, width, height, AV_PIX_FMT_RGB24, SWS_BICUBIC, NULL, NULL, NULL);
-
- if (!img_convert_ctx) {
- debug_error(DEBUG, "failed to get img convet ctx\n");
- ret = MMFILE_FORMAT_FAIL;
- goto exception;
- }
+ mm_file_retvm_if_fails(DEBUG, img_convert_ctx, false);
av_err = sws_scale(img_convert_ctx, (const uint8_t * const *)pFrame->data, pFrame->linesize, 0, height, dst_data, dst_linesize);
+ sws_freeContext(img_convert_ctx);
if (av_err < 0) {
- debug_error(DEBUG, "failed to convet image\n");
- ret = MMFILE_FORMAT_FAIL;
- goto exception;
+ debug_error(DEBUG, "failed to convet image");
+ return false;
}
-exception:
- sws_freeContext(img_convert_ctx);
- img_convert_ctx = NULL;
- return ret;
+ return true;
}
-static int __mmfile_get_frame(AVFormatContext *pFormatCtx, int64_t timestamp, bool is_accurate, unsigned char **frame, int *size, int *width, int *height)
+static int __mmfile_get_frame(AVFormatContext *pFormatCtx,
+ int64_t timestamp,
+ bool is_accurate,
+ unsigned char **frame,
+ int *size,
+ int *width,
+ int *height)
{
int ret = MMFILE_FORMAT_SUCCESS;
int videoStream = -1;
AVCodecContext *pVideoCodecCtx = NULL;
- bool find = false;
AVFrame *pFrame = NULL;
/* Retrieve stream information */
- if (avformat_find_stream_info(pFormatCtx, NULL) < 0) {
- debug_error(DEBUG, "error : av_find_stream_info failed");
- ret = MMFILE_FORMAT_FAIL;
- goto exception; /* Couldn't find stream information */
- }
+ mm_file_retvm_if_fails(DEBUG, avformat_find_stream_info(pFormatCtx, NULL) >= 0, MMFILE_FORMAT_FAIL);
/* Find the first video stream */
- ret = __mmfile_get_first_video_stream(pFormatCtx, &videoStream);
- if (MMFILE_FORMAT_FAIL == ret) {
- debug_error(DEBUG, "error : __mmfile_get_first_video_stream");
- goto exception; /* Didn't find a video stream */
- }
-
- ret = __mmfile_open_video_codec(pFormatCtx, videoStream, &pVideoCodecCtx);
- if (MMFILE_FORMAT_FAIL == ret) {
- debug_error(DEBUG, "error : __mmfile_open_video_codec");
- goto exception; /*Could not open codec */
- }
+ mm_file_retvm_if_fails(DEBUG, __mmfile_get_first_video_stream(pFormatCtx, &videoStream), MMFILE_FORMAT_FAIL);
+ mm_file_retvm_if_fails(DEBUG, __mmfile_open_video_codec(pFormatCtx, videoStream, &pVideoCodecCtx), MMFILE_FORMAT_FAIL);
/* Storing Data */
/* Allocate video frame */
pFrame = av_frame_alloc();
if (!pFrame) {
- debug_error(DEBUG, "error: pFrame is NULL\n");
+ debug_error(DEBUG, "error: pFrame is NULL");
ret = MMFILE_FORMAT_FAIL;
goto exception;
}
/* Seeking */
- ret = __mmfile_seek_to_pos(pFormatCtx, timestamp, is_accurate);
- if (MMFILE_FORMAT_FAIL == ret) {
+ if (!__mmfile_seek_to_pos(pFormatCtx, timestamp, is_accurate)) {
debug_error(DEBUG, "error : __mmfile_seek_to_pos");
goto exception; /*Could not seek to timestamp */
}
/* Reading Data */
- find = __mmfile_find_proper_frame(pFormatCtx, videoStream, pVideoCodecCtx, timestamp, is_accurate, pFrame);
-
- /* Did we get a video frame?*/
- if (!find) {
- debug_error(DEBUG, "Not Found Proper Frame[%d]", find);
+ if (!__mmfile_find_proper_frame(pFormatCtx, videoStream, pVideoCodecCtx, timestamp, is_accurate, pFrame)) {
+ debug_error(DEBUG, "Not Found Proper Frame");
ret = MMFILE_FORMAT_FAIL;
goto exception;
}
}
*size = av_image_get_buffer_size(AV_PIX_FMT_RGB24, *width, *height, 1);
-
- if (*size <=0 ) {
- debug_error(DEBUG, "error: av_image_get_buffer_size. [%d]\n", *size);
+ if (*size <= 0) {
+ debug_error(DEBUG, "error: av_image_get_buffer_size. [%d]", *size);
ret = MMFILE_FORMAT_FAIL;
goto exception;
}
debug_msg(RELEASE, "height : %d", *height);
debug_msg(RELEASE, "frame : %p", *frame);
- ret = __mmfile_swscale_frame(pVideoCodecCtx, pFrame, *width, *height, *frame, *size);
- if (MMFILE_FORMAT_FAIL == ret) {
+ if (!__mmfile_swscale_frame(pVideoCodecCtx, pFrame, *width, *height, *frame, *size)) {
debug_error(DEBUG, "error : __mmfile_scale_frame");
ret = MMFILE_FORMAT_FAIL;
goto exception;
#endif
debug_msg(RELEASE, "frame : %p", *frame);
- if (pFrame) av_frame_free(&pFrame);
- if (pVideoCodecCtx) avcodec_free_context(&pVideoCodecCtx);
+ if (pFrame)
+ av_frame_free(&pFrame);
+ if (pVideoCodecCtx)
+ avcodec_free_context(&pVideoCodecCtx);
return MMFILE_FORMAT_SUCCESS;
exception:
mmfile_free(*frame);
- if (pFrame) av_frame_free(&pFrame);
- if (pVideoCodecCtx) avcodec_free_context(&pVideoCodecCtx);
+ if (pFrame)
+ av_frame_free(&pFrame);
+ if (pVideoCodecCtx)
+ avcodec_free_context(&pVideoCodecCtx);
return ret;
}
int ret = MMFILE_FORMAT_SUCCESS;
AVFormatContext *pFormatCtx = NULL;
- if (!size || !width || !height) {
- return MMFILE_FORMAT_FAIL;
- }
+ mm_file_retv_if_fails(size, MMFILE_FORMAT_FAIL);
+ mm_file_retv_if_fails(width, MMFILE_FORMAT_FAIL);
+ mm_file_retv_if_fails(height, MMFILE_FORMAT_FAIL);
av_register_all();
/* Open video file */
- if (avformat_open_input(&pFormatCtx, path, NULL, NULL) != 0) {
- debug_error(DEBUG, "error : avformat_open_input failed");
- return MMFILE_FORMAT_FAIL; /* Couldn't open file */
- }
-
- if (!pFormatCtx) {
- debug_warning(DEBUG, "failed to find av stream. maybe corrupted data.\n");
- ret = MMFILE_FORMAT_FAIL;
- goto exception;
- }
+ mm_file_retvm_if_fails(DEBUG, avformat_open_input(&pFormatCtx, path, NULL, NULL) == 0, MMFILE_FORMAT_FAIL);
ret = __mmfile_get_frame(pFormatCtx, timestamp, is_accurate, frame, size, width, height);
-
-exception:
- /* Close video file */
- if (pFormatCtx) avformat_close_input(&pFormatCtx);
+ avformat_close_input(&pFormatCtx);
return ret;
}
MMFmemIOHandle *handle = NULL;
uint8_t *avio_ctx_buffer = NULL;
- if (!size || !width || !height) {
- return MMFILE_FORMAT_FAIL;
- }
+ mm_file_retv_if_fails(size, MMFILE_FORMAT_FAIL);
+ mm_file_retv_if_fails(width, MMFILE_FORMAT_FAIL);
+ mm_file_retv_if_fails(height, MMFILE_FORMAT_FAIL);
av_register_all();
mmfile_register_io_all();
- ret = __get_fileformat(urifilename, &format);
- if (ret != MMFILE_FORMAT_SUCCESS) {
- debug_error(DEBUG, "error: file format is invalid\n");
- return MMFILE_FORMAT_FAIL;
- }
-
- if (mmfile_util_get_mimetype(format, mimeType, MMFILE_MIMETYPE_MAX_LEN) < 0) {
- debug_error(DEBUG, "error: Error in MIME Type finding\n");
- return MMFILE_FORMAT_FAIL;
- }
-
- memset(ffmpegFormatName, 0x00, MMFILE_FILE_FMT_MAX_LEN);
-
- ret = mmfile_util_get_ffmpeg_format(mimeType, ffmpegFormatName);
-
- if (MMFILE_UTIL_SUCCESS != ret) {
- debug_error(DEBUG, "error: mmfile_util_get_ffmpeg_format\n");
- return MMFILE_FORMAT_FAIL;
- }
+ mm_file_retvm_if_fails(DEBUG, __get_fileformat(urifilename, &format), MMFILE_FORMAT_FAIL);
+ mm_file_retvm_if_fails(DEBUG, mmfile_util_get_mimetype(format, mimeType, MMFILE_MIMETYPE_MAX_LEN) == MMFILE_UTIL_SUCCESS, MMFILE_FORMAT_FAIL);
+ mm_file_retvm_if_fails(DEBUG, mmfile_util_get_ffmpeg_format(mimeType, ffmpegFormatName) == MMFILE_UTIL_SUCCESS, MMFILE_FORMAT_FAIL);
grab_iformat = av_find_input_format(ffmpegFormatName);
-
- if (NULL == grab_iformat) {
- debug_error(DEBUG, "error: cannot find format\n");
- ret = MMFILE_FORMAT_FAIL;
- goto exception;
- }
+ mm_file_retvm_if_fails(DEBUG, grab_iformat, MMFILE_FORMAT_FAIL);
avio_ctx_buffer = av_malloc(MMFILE_AVIO_BUFFER_LEN);
- if (avio_ctx_buffer == NULL) {
- debug_error(DEBUG, "error: cannot alloc avio_ctx_buffert\n");
- ret = MMFILE_FORMAT_FAIL;
- goto exception;
- }
+ mm_file_retvm_if_fails(DEBUG, avio_ctx_buffer, MMFILE_FORMAT_FAIL);
- ret = _mmf_mem_open(&handle, urifilename);
- if (ret != MMFILE_UTIL_SUCCESS) {
- debug_warning(DEBUG, "failed to _mmf_mem_open.\n");
+ if (!__mmf_mem_open(&handle, urifilename)) {
+ debug_warning(DEBUG, "failed to __mmf_mem_open.");
av_free(avio_ctx_buffer);
- ret = MMFILE_FORMAT_FAIL;
- goto exception;
+ return MMFILE_FORMAT_FAIL;
}
- pIOCtx = avio_alloc_context(avio_ctx_buffer, MMFILE_AVIO_BUFFER_LEN, 0, handle, _mmf_mem_read, NULL, _mmf_mem_seek);
+ pIOCtx = avio_alloc_context(avio_ctx_buffer, MMFILE_AVIO_BUFFER_LEN, 0, handle, __mmf_mem_read, NULL, __mmf_mem_seek);
if (pIOCtx == NULL) {
- debug_error(DEBUG, "error: cannot alloc io context\n");
+ debug_error(DEBUG, "error: cannot alloc io context");
av_free(avio_ctx_buffer);
mmfile_free(handle);
ret = MMFILE_FORMAT_FAIL;
pFormatCtx = avformat_alloc_context();
if (!pFormatCtx) {
- debug_warning(DEBUG, "failed to avformat_alloc_context\n");
+ debug_warning(DEBUG, "failed to avformat_alloc_context");
ret = MMFILE_FORMAT_FAIL;
goto exception;
}
pFormatCtx->pb = pIOCtx;
- ret = avformat_open_input(&pFormatCtx, "", grab_iformat, NULL);
- if (ret < 0) {
- debug_error(DEBUG, "error: cannot open %s %d\n", urifilename, ret);
+ if (avformat_open_input(&pFormatCtx, "", grab_iformat, NULL) < 0) {
+ debug_error(DEBUG, "error: cannot open %s", urifilename);
+ ret = MMFILE_FORMAT_FAIL;
goto exception;
}