Re #1182:
- Fixed ffmpeg codec: decoding buffer size check (should not use assertion), reset output bit_info before decoding, removed unused code of auto resize when decoder output size changed. - Fixed bug in sdl_factory_default_param() of sdl_dev.c in device direction check. - Fixed compile errors sample app vid_streamutil.c of bad local variable definiton. - Updated sample app vid_streamutil.c default renderer size to 640 x 480. git-svn-id: https://svn.pjsip.org/repos/pjproject/branches/projects/2.0-dev@3432 74dad513-b988-da41-8d7b-12977e46ad98
This commit is contained in:
parent
4a20bc808a
commit
9861070228
|
@ -1272,8 +1272,12 @@ static pj_status_t ffmpeg_codec_decode( pjmedia_vid_codec *codec,
|
|||
/* Check if decoder has been opened */
|
||||
PJ_ASSERT_RETURN(ff->dec_ctx, PJ_EINVALIDOP);
|
||||
|
||||
/* Reset output frame bit info */
|
||||
output->bit_info = 0;
|
||||
|
||||
/* Validate output buffer size */
|
||||
//PJ_ASSERT_RETURN(ff->dec_vafp.framebytes <= output_buf_len, PJ_ETOOSMALL);
|
||||
if (ff->dec_vafp.framebytes > output_buf_len)
|
||||
return PJ_ETOOSMALL;
|
||||
|
||||
/* Init frame to receive the decoded data, the ffmpeg codec context will
|
||||
* automatically provide the decoded buffer (single buffer used for the
|
||||
|
@ -1325,36 +1329,6 @@ static pj_status_t ffmpeg_codec_decode( pjmedia_vid_codec *codec,
|
|||
ff->dec_ctx->coded_width != (int)vafp->size.w ||
|
||||
ff->dec_ctx->coded_height != (int)vafp->size.h)
|
||||
{
|
||||
#if 0
|
||||
// it should not be the codec responsibility to do resizing
|
||||
pj_uint8_t *data[PJMEDIA_MAX_VIDEO_PLANES] = {0};
|
||||
unsigned i;
|
||||
int h;
|
||||
|
||||
if (!ff->sws_ctx) {
|
||||
pj_assert(sws_isSupportedInput(ff->dec_ctx->pix_fmt) > 0);
|
||||
pj_assert(sws_isSupportedOutput(ff->expected_dec_fmt) > 0);
|
||||
ff->sws_ctx = sws_getContext(ff->dec_ctx->coded_width,
|
||||
ff->dec_ctx->coded_height,
|
||||
ff->dec_ctx->pix_fmt,
|
||||
vafp->size.w, vafp->size.h,
|
||||
ff->expected_dec_fmt,
|
||||
SWS_BILINEAR | SWS_PRINT_INFO,
|
||||
NULL, NULL, NULL);
|
||||
if (ff->sws_ctx == NULL) {
|
||||
return PJ_EUNKNOWN;
|
||||
}
|
||||
}
|
||||
|
||||
for (i = 0; i < ff->vfi->plane_cnt; ++i) {
|
||||
data[i] = q;
|
||||
q += vafp->plane_bytes[i];
|
||||
}
|
||||
h = sws_scale(ff->sws_ctx, avframe.data, avframe.linesize, 0,
|
||||
ff->dec_ctx->coded_height, data, vafp->strides);
|
||||
pj_assert((int)vafp->size.h == h);
|
||||
#endif
|
||||
|
||||
pjmedia_format_id new_fmt_id;
|
||||
pj_status_t status;
|
||||
|
||||
|
@ -1382,11 +1356,11 @@ static pj_status_t ffmpeg_codec_decode( pjmedia_vid_codec *codec,
|
|||
|
||||
/* Notify application via the bit_info field of pjmedia_frame */
|
||||
output->bit_info = PJMEDIA_VID_CODEC_EVENT_FMT_CHANGED;
|
||||
}
|
||||
|
||||
/* Check provided buffer size after format changed */
|
||||
//if (vafp->framebytes > output_buf_len)
|
||||
//return PJ_ETOOSMALL;
|
||||
if (vafp->framebytes > output_buf_len)
|
||||
return PJ_ETOOSMALL;
|
||||
}
|
||||
|
||||
/* Get the decoded data */
|
||||
for (i = 0; i < ff->dec_vfi->plane_cnt; ++i) {
|
||||
|
|
|
@ -280,7 +280,7 @@ static pj_status_t sdl_factory_default_param(pj_pool_t *pool,
|
|||
PJ_UNUSED_ARG(pool);
|
||||
|
||||
pj_bzero(param, sizeof(*param));
|
||||
if (di->info.dir & PJMEDIA_DIR_CAPTURE_RENDER) {
|
||||
if (di->info.dir == PJMEDIA_DIR_CAPTURE_RENDER) {
|
||||
param->dir = PJMEDIA_DIR_CAPTURE_RENDER;
|
||||
param->cap_id = index;
|
||||
param->rend_id = index;
|
||||
|
@ -750,6 +750,9 @@ static pj_status_t sdl_stream_put_frame(pjmedia_vid_dev_stream *strm,
|
|||
goto on_return;
|
||||
}
|
||||
|
||||
if (frame->size==0 || frame->buf==NULL)
|
||||
goto on_return;
|
||||
|
||||
if (stream->surf) {
|
||||
if (SDL_MUSTLOCK(stream->surf)) {
|
||||
if (SDL_LockSurface(stream->surf) < 0) {
|
||||
|
|
|
@ -88,9 +88,17 @@ static const char *desc =
|
|||
|
||||
#define THIS_FILE "vid_streamutil.c"
|
||||
|
||||
|
||||
/* If set, local renderer will be created to play original file */
|
||||
#define HAS_LOCAL_RENDERER_FOR_PLAY_FILE 1
|
||||
#define DEF_RENDERER_WIDTH 0
|
||||
#define DEF_RENDERER_HEIGHT 0
|
||||
|
||||
|
||||
/* Default width and height for the renderer, better be set to maximum
|
||||
* acceptable size.
|
||||
*/
|
||||
#define DEF_RENDERER_WIDTH 640
|
||||
#define DEF_RENDERER_HEIGHT 480
|
||||
|
||||
|
||||
/* Prototype */
|
||||
static void print_stream_stat(pjmedia_vid_stream *stream,
|
||||
|
@ -597,7 +605,7 @@ int main(int argc, char *argv[])
|
|||
|
||||
if (play_file.file_name) {
|
||||
pjmedia_video_format_detail *file_vfd;
|
||||
pjmedia_clock_param *clock_param;
|
||||
pjmedia_clock_param clock_param;
|
||||
|
||||
/* Create file player */
|
||||
status = create_file_player(pool, play_file.file_name, &play_port);
|
||||
|
|
Loading…
Reference in New Issue