From 08022744da3e8e5df7c380e033397b8f74346a5e Mon Sep 17 00:00:00 2001 From: cigaes Date: Sat, 21 Sep 2024 09:30:09 +0000 Subject: [PATCH] libmpdemux/demux_lavf: explicit pointer casts Recent compilers consider implicit casts an error. git-svn-id: svn://git.mplayerhq.hu/mplayer/trunk@38650 b3059339-0415-0410-9bf9-f77b7e298cf2 --- libmpdemux/demux_lavf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libmpdemux/demux_lavf.c b/libmpdemux/demux_lavf.c index 06a9e15cc..60b15f0f6 100644 --- a/libmpdemux/demux_lavf.c +++ b/libmpdemux/demux_lavf.c @@ -378,7 +378,7 @@ static void handle_stream(demuxer_t *demuxer, AVFormatContext *avfc, int i) { } case AVMEDIA_TYPE_VIDEO:{ AVDictionaryEntry *rot = av_dict_get(st->metadata, "rotate", NULL, 0); - const int32_t *disp_matrix = av_stream_get_side_data(st, AV_PKT_DATA_DISPLAYMATRIX, NULL); + const int32_t *disp_matrix = (const int32_t *)av_stream_get_side_data(st, AV_PKT_DATA_DISPLAYMATRIX, NULL); sh_video_t* sh_video; BITMAPINFOHEADER *bih; sh_video=new_sh_video_vid(demuxer, i, priv->video_streams); -- 2.25.1 From 151b9e0bc961a18036f91af046a4e2e1fbfcf09c Mon Sep 17 00:00:00 2001 From: cigaes Date: Sat, 21 Sep 2024 09:30:07 +0000 Subject: [PATCH] libmpcodecs/vf_screenshot: explicit pointer casts Recent compilers consider implicit casts an error. git-svn-id: svn://git.mplayerhq.hu/mplayer/trunk@38648 b3059339-0415-0410-9bf9-f77b7e298cf2 --- libmpcodecs/vf_screenshot.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libmpcodecs/vf_screenshot.c b/libmpcodecs/vf_screenshot.c index e8b87fa91..4aa5ee274 100644 --- a/libmpcodecs/vf_screenshot.c +++ b/libmpcodecs/vf_screenshot.c @@ -60,7 +60,7 @@ static void draw_slice(struct vf_instance *vf, unsigned char** src, int* stride, int w,int h, int x, int y) { if (vf->priv->store_slices) { - sws_scale(vf->priv->ctx, src, stride, y, h, vf->priv->pic->data, vf->priv->pic->linesize); + sws_scale(vf->priv->ctx, (const uint8_t *const *)src, stride, y, h, vf->priv->pic->data, vf->priv->pic->linesize); } vf_next_draw_slice(vf,src,stride,w,h,x,y); } @@ -158,7 +158,7 @@ static void scale_image(struct vf_priv_s* priv, mp_image_t *mpi) if (!priv->pic->data[0]) priv->pic->data[0] = av_malloc(priv->pic->linesize[0]*priv->dh); - sws_scale(priv->ctx, mpi->planes, mpi->stride, 0, mpi->height, priv->pic->data, priv->pic->linesize); + sws_scale(priv->ctx, (const uint8_t *const *)mpi->planes, mpi->stride, 0, mpi->height, priv->pic->data, priv->pic->linesize); } static void start_slice(struct vf_instance *vf, mp_image_t *mpi) -- 2.25.1 From 314fbd1cf96ee9fc317eb6c2054db5f76c94e930 Mon Sep 17 00:00:00 2001 From: cigaes Date: Sat, 21 Sep 2024 09:30:17 +0000 Subject: [PATCH] sub/spudec: explicit pointer casts Recent compilers consider implicit casts an error. git-svn-id: svn://git.mplayerhq.hu/mplayer/trunk@38659 b3059339-0415-0410-9bf9-f77b7e298cf2 --- sub/spudec.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sub/spudec.c b/sub/spudec.c index eefc235d4..516ce52e6 100644 --- a/sub/spudec.c +++ b/sub/spudec.c @@ -897,9 +897,9 @@ static void sws_spu_image(unsigned char *d1, unsigned char *d2, int dw, int dh, } ctx=sws_getContext(sw, sh, AV_PIX_FMT_GRAY8, dw, dh, AV_PIX_FMT_GRAY8, SWS_GAUSS, &filter, NULL, NULL); - sws_scale(ctx,&s1,&ss,0,sh,&d1,&ds); + sws_scale(ctx,(const uint8_t *const *)&s1,&ss,0,sh,&d1,&ds); for (i=ss*sh-1; i>=0; i--) s2[i] = -s2[i]; - sws_scale(ctx,&s2,&ss,0,sh,&d2,&ds); + sws_scale(ctx,(const uint8_t *const *)&s2,&ss,0,sh,&d2,&ds); for (i=ds*dh-1; i>=0; i--) d2[i] = -d2[i]; sws_freeContext(ctx); } -- 2.25.1 From 36604b124a5f1e75929b1bfb097c87010182fe3e Mon Sep 17 00:00:00 2001 From: cigaes Date: Sat, 21 Sep 2024 09:30:13 +0000 Subject: [PATCH] loader/qtx/qtxsdk/components: explicit pointer casts Recent compilers consider implicit casts an error. git-svn-id: svn://git.mplayerhq.hu/mplayer/trunk@38655 b3059339-0415-0410-9bf9-f77b7e298cf2 --- loader/qtx/qtxsdk/components.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/loader/qtx/qtxsdk/components.h b/loader/qtx/qtxsdk/components.h index 5ad7572d8..d3109effa 100644 --- a/loader/qtx/qtxsdk/components.h +++ b/loader/qtx/qtxsdk/components.h @@ -780,7 +780,7 @@ static inline void dump_CodecDecompressParams(void* xxx){ printf("dstrect: %d;%d - %d;%d\n",cd->dstRect.top,cd->dstRect.left,cd->dstRect.bottom,cd->dstRect.right); printf("wantedDestinationPixelTypes=%p\n",cd->wantedDestinationPixelTypes); if(cd->wantedDestinationPixelTypes){ - unsigned int* p=cd->wantedDestinationPixelTypes; + unsigned int* p=(unsigned *)cd->wantedDestinationPixelTypes; while(p[0]){ printf(" 0x%08X %p\n",p[0],&p[0]); ++p; -- 2.25.1 From 390f2c186b209ee9017968a40788e39fb56aab11 Mon Sep 17 00:00:00 2001 From: cigaes Date: Sat, 21 Sep 2024 09:30:16 +0000 Subject: [PATCH] sub/sub: explicit pointer casts Recent compilers consider implicit casts an error. git-svn-id: svn://git.mplayerhq.hu/mplayer/trunk@38658 b3059339-0415-0410-9bf9-f77b7e298cf2 --- sub/sub.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sub/sub.c b/sub/sub.c index 142242179..7bad030d5 100644 --- a/sub/sub.c +++ b/sub/sub.c @@ -727,7 +727,7 @@ static inline void vo_update_text_sub(mp_osd_obj_t *obj, int dxs, int dys) // reading the subtitle words from vo_sub->text[] while (*t) { if (sub_utf8) - c = utf8_get_char(&t); + c = utf8_get_char((const char **)&t); else if ((c = *t++) >= 0x80 && sub_unicode) c = (c<<8) + *t++; if (k==MAX_UCS){ -- 2.25.1 From 4128ed0ed69236c0dda18abbe590682c40653f0d Mon Sep 17 00:00:00 2001 From: cigaes Date: Sat, 21 Sep 2024 09:30:09 +0000 Subject: [PATCH] libmpdemux/muxer_avi: explicit pointer casts Recent compilers consider implicit casts an error. git-svn-id: svn://git.mplayerhq.hu/mplayer/trunk@38651 b3059339-0415-0410-9bf9-f77b7e298cf2 --- libmpdemux/muxer_avi.c | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/libmpdemux/muxer_avi.c b/libmpdemux/muxer_avi.c index 78a666770..912e6cde2 100644 --- a/libmpdemux/muxer_avi.c +++ b/libmpdemux/muxer_avi.c @@ -142,8 +142,8 @@ static muxer_stream_t* avifile_new_stream(muxer_t *muxer,int type){ static void write_avi_chunk(stream_t *stream,unsigned int id,int len,void* data){ int le_len = le2me_32(len); int le_id = le2me_32(id); - stream_write_buffer(stream, &le_id, 4); - stream_write_buffer(stream, &le_len, 4); + stream_write_buffer(stream, (unsigned char *)&le_id, 4); + stream_write_buffer(stream, (unsigned char *)&le_len, 4); if(len>0){ if(data){ @@ -176,9 +176,9 @@ static void write_avi_list(stream_t *stream, unsigned int id, int len) list_id = le2me_32(list_id); le_len = le2me_32(len); le_id = le2me_32(id); - stream_write_buffer(stream, &list_id, 4); - stream_write_buffer(stream, &le_len, 4); - stream_write_buffer(stream, &le_id, 4); + stream_write_buffer(stream, (unsigned char *)&list_id, 4); + stream_write_buffer(stream, (unsigned char *)&le_len, 4); + stream_write_buffer(stream, (unsigned char *)&le_id, 4); } static void avifile_odml_new_riff(muxer_t *muxer) @@ -199,7 +199,7 @@ static void avifile_odml_new_riff(muxer_t *muxer) riff[0]=le2me_32(mmioFOURCC('R','I','F','F')); riff[1]=0; riff[2]=le2me_32(mmioFOURCC('A','V','I','X')); - stream_write_buffer(muxer->stream, riff, 12); + stream_write_buffer(muxer->stream, (unsigned char *)riff, 12); write_avi_list(muxer->stream,listtypeAVIMOVIE,0); @@ -251,12 +251,12 @@ static void avifile_write_header(muxer_t *muxer){ movilen = le2me_32(rifflen - 12); rifflen = le2me_32(rifflen); stream_seek(muxer->stream, vsi->riffofs[i]+4); - stream_write_buffer(muxer->stream,&rifflen,4); + stream_write_buffer(muxer->stream,(unsigned char *)&rifflen,4); /* fixup movi length */ if (i > 0) { stream_seek(muxer->stream, vsi->riffofs[i]+16); - stream_write_buffer(muxer->stream,&movilen,4); + stream_write_buffer(muxer->stream,(unsigned char *)&movilen,4); } } @@ -269,7 +269,7 @@ static void avifile_write_header(muxer_t *muxer){ riff[0]=le2me_32(riff[0]); riff[1]=le2me_32(riff[1]); riff[2]=le2me_32(riff[2]); - stream_write_buffer(muxer->stream,&riff,12); + stream_write_buffer(muxer->stream,(unsigned char *)&riff,12); } // update AVI header: @@ -406,7 +406,7 @@ static void avifile_write_header(muxer_t *muxer){ idxhdr[6] = 0; idxhdr[7] = 0; - stream_write_buffer(muxer->stream,idxhdr,sizeof(idxhdr)); + stream_write_buffer(muxer->stream,(unsigned char *)idxhdr,sizeof(idxhdr)); for (j=0; jsuperidx[j]; unsigned int data[4]; @@ -414,7 +414,7 @@ static void avifile_write_header(muxer_t *muxer){ data[1] = le2me_32(entry->ofs >> 32); data[2] = le2me_32(entry->len); data[3] = le2me_32(entry->duration); - stream_write_buffer(muxer->stream,data,sizeof(data)); + stream_write_buffer(muxer->stream,(unsigned char *)data,sizeof(data)); } } } @@ -642,13 +642,13 @@ static void avifile_odml_write_index(muxer_t *muxer){ si->superidx[j].ofs = stream_tell(muxer->stream); si->superidx[j].duration = duration; - stream_write_buffer(muxer->stream, idxhdr,sizeof(idxhdr)); + stream_write_buffer(muxer->stream, (unsigned char *)idxhdr,sizeof(idxhdr)); for (k=0; kidxpos; k++) { unsigned int entry[2]; entry[0] = le2me_32(si->idx[idxpos].ofs - start); entry[1] = le2me_32(si->idx[idxpos].len | si->idx[idxpos].flags); idxpos++; - stream_write_buffer(muxer->stream, entry, sizeof(entry)); + stream_write_buffer(muxer->stream, (unsigned char *)entry, sizeof(entry)); } } } -- 2.25.1 From 4d3182896b00c11a3c16bcc4fc4870967f08d391 Mon Sep 17 00:00:00 2001 From: cigaes Date: Sat, 21 Sep 2024 09:30:08 +0000 Subject: [PATCH] libmpdemux/demux_film: explicit pointer casts Recent compilers consider implicit casts an error. git-svn-id: svn://git.mplayerhq.hu/mplayer/trunk@38649 b3059339-0415-0410-9bf9-f77b7e298cf2 --- libmpdemux/demux_film.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libmpdemux/demux_film.c b/libmpdemux/demux_film.c index fdb391ddd..b351368e4 100644 --- a/libmpdemux/demux_film.c +++ b/libmpdemux/demux_film.c @@ -157,7 +157,7 @@ static int demux_film_fill_buffer(demuxer_t *demuxer, demux_stream_t *ds) free(buf); } else {/* for 16bit */ - unsigned short* tmp = dp->buffer; + unsigned short* tmp = (unsigned short *)dp->buffer; unsigned short* buf = malloc(film_chunk.chunk_size); for(i = 0; i < film_chunk.chunk_size/4; i++) { buf[i*2] = tmp[i]; -- 2.25.1 From 583aefee6d254244ec4f9c35fc7659555498caa0 Mon Sep 17 00:00:00 2001 From: cigaes Date: Sat, 21 Sep 2024 09:30:05 +0000 Subject: [PATCH] libmpcodecs/vf_pp: explicit pointer casts Recent compilers consider implicit casts an error. git-svn-id: svn://git.mplayerhq.hu/mplayer/trunk@38646 b3059339-0415-0410-9bf9-f77b7e298cf2 --- libmpcodecs/vf_pp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libmpcodecs/vf_pp.c b/libmpcodecs/vf_pp.c index 9721554d0..935677be6 100644 --- a/libmpcodecs/vf_pp.c +++ b/libmpcodecs/vf_pp.c @@ -142,7 +142,7 @@ static int put_image(struct vf_instance *vf, mp_image_t *mpi, double pts, double if(vf->priv->pp || !(mpi->flags&MP_IMGFLAG_DIRECT)){ // do the postprocessing! (or copy if no DR) - pp_postprocess(mpi->planes ,mpi->stride, + pp_postprocess((const uint8_t **)mpi->planes ,mpi->stride, vf->dmpi->planes,vf->dmpi->stride, (mpi->w+7)&(~7),mpi->h, mpi->qscale, mpi->qstride, -- 2.25.1 From 62f75720e743badb1407e4efa3c831900e475a9a Mon Sep 17 00:00:00 2001 From: cigaes Date: Sat, 21 Sep 2024 09:30:10 +0000 Subject: [PATCH] libvo/vo_aa: explicit pointer casts Recent compilers consider implicit casts an error. git-svn-id: svn://git.mplayerhq.hu/mplayer/trunk@38652 b3059339-0415-0410-9bf9-f77b7e298cf2 --- libvo/vo_aa.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libvo/vo_aa.c b/libvo/vo_aa.c index dc805be5b..599a938ab 100644 --- a/libvo/vo_aa.c +++ b/libvo/vo_aa.c @@ -357,7 +357,7 @@ draw_frame(uint8_t *src[]) { break; } - sws_scale(sws,src,stride,0,src_height,image,image_stride); + sws_scale(sws,(const uint8_t *const *)src,stride,0,src_height,image,image_stride); /* Now 'ASCIInate' the image */ if (fast) @@ -377,7 +377,7 @@ draw_slice(uint8_t *src[], int stride[], int dx2 = screen_x + ((x+w) * screen_w / src_width); int dy2 = screen_y + ((y+h) * screen_h / src_height); - sws_scale(sws,src,stride,y,h,image,image_stride); + sws_scale(sws,(const uint8_t *const *)src,stride,y,h,image,image_stride); /* Now 'ASCIInate' the image */ if (fast) -- 2.25.1 From 6863cf457bb0f0b98dde19dd85c666191130c7d6 Mon Sep 17 00:00:00 2001 From: cigaes Date: Sat, 21 Sep 2024 09:30:14 +0000 Subject: [PATCH] mp_msg: explicit pointer casts Recent compilers consider implicit casts an error. git-svn-id: svn://git.mplayerhq.hu/mplayer/trunk@38656 b3059339-0415-0410-9bf9-f77b7e298cf2 --- mp_msg.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mp_msg.c b/mp_msg.c index 67bcc067d..3b059801a 100644 --- a/mp_msg.c +++ b/mp_msg.c @@ -70,7 +70,7 @@ const char* filename_recode(const char* filename) filename_len = strlen(filename); max_path = MSGSIZE_MAX - 4; precoded = recoded_filename; - if (iconv(inv_msgiconv, &filename, &filename_len, + if (iconv(inv_msgiconv, (char **)&filename, &filename_len, &precoded, &max_path) == (size_t)(-1) && errno == E2BIG) { precoded[0] = precoded[1] = precoded[2] = '.'; precoded += 3; -- 2.25.1 From 8dea6f4931b7677a93ad6394b8ad021207dd0442 Mon Sep 17 00:00:00 2001 From: cigaes Date: Sat, 21 Sep 2024 09:30:11 +0000 Subject: [PATCH] libvo/vo_matrixview: explicit pointer casts Recent compilers consider implicit casts an error. git-svn-id: svn://git.mplayerhq.hu/mplayer/trunk@38653 b3059339-0415-0410-9bf9-f77b7e298cf2 --- libvo/vo_matrixview.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libvo/vo_matrixview.c b/libvo/vo_matrixview.c index ee2735b1c..632ec4e59 100644 --- a/libvo/vo_matrixview.c +++ b/libvo/vo_matrixview.c @@ -170,7 +170,7 @@ static void flip_page(void) static int draw_slice(uint8_t *src[], int stride[], int w, int h, int x, int y) { - sws_scale(sws, src, stride, y, h, map_image, map_stride); + sws_scale(sws, (const uint8_t *const *)src, stride, y, h, map_image, map_stride); return 0; } -- 2.25.1 From b4f1865ca5053d8b3d7f131c27e515e69374afcb Mon Sep 17 00:00:00 2001 From: cigaes Date: Sat, 21 Sep 2024 09:30:04 +0000 Subject: [PATCH] libmpcodecs/vd_ffmpeg: explicit pointer casts Recent compilers consider implicit casts an error. git-svn-id: svn://git.mplayerhq.hu/mplayer/trunk@38645 b3059339-0415-0410-9bf9-f77b7e298cf2 --- libmpcodecs/vd_ffmpeg.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libmpcodecs/vd_ffmpeg.c b/libmpcodecs/vd_ffmpeg.c index b112a2669..2d2fc7281 100644 --- a/libmpcodecs/vd_ffmpeg.c +++ b/libmpcodecs/vd_ffmpeg.c @@ -728,7 +728,7 @@ static int get_buffer(AVCodecContext *avctx, AVFrame *pic, int isreference){ if (ctx->use_vdpau) { VdpVideoSurface surface = (VdpVideoSurface)mpi->priv; avctx->draw_horiz_band= NULL; - mpi->planes[3] = surface; + mpi->planes[3] = (char *)surface; } #endif -- 2.25.1 From bb6d913176c79d073be117e32e0dfcd2f6c4bf35 Mon Sep 17 00:00:00 2001 From: cigaes Date: Sat, 21 Sep 2024 09:30:12 +0000 Subject: [PATCH] libvo/vo_x11: explicit pointer casts Recent compilers consider implicit casts an error. git-svn-id: svn://git.mplayerhq.hu/mplayer/trunk@38654 b3059339-0415-0410-9bf9-f77b7e298cf2 --- libvo/vo_x11.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libvo/vo_x11.c b/libvo/vo_x11.c index c3ec528a4..f39076810 100644 --- a/libvo/vo_x11.c +++ b/libvo/vo_x11.c @@ -492,7 +492,7 @@ static int draw_slice(uint8_t * src[], int stride[], int w, int h, dst[0] += dstStride[0] * (image_height - 1); dstStride[0] = -dstStride[0]; } - sws_scale(swsContext, src, stride, y, h, dst, dstStride); + sws_scale(swsContext, (const uint8_t *const *)src, stride, y, h, dst, dstStride); return 0; } -- 2.25.1 From df9a6b2d6235c064eca0f24d0c45c89d0524bd7a Mon Sep 17 00:00:00 2001 From: cigaes Date: Sat, 21 Sep 2024 09:30:15 +0000 Subject: [PATCH] mplayer: explicit pointer casts Recent compilers consider implicit casts an error. git-svn-id: svn://git.mplayerhq.hu/mplayer/trunk@38657 b3059339-0415-0410-9bf9-f77b7e298cf2 --- mplayer.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mplayer.c b/mplayer.c index 952971c09..a63d4735e 100644 --- a/mplayer.c +++ b/mplayer.c @@ -3538,7 +3538,7 @@ goto_enable_cache: break; if ((mpctx->demuxer->file_format == DEMUXER_TYPE_AVI || mpctx->demuxer->file_format == DEMUXER_TYPE_ASF || mpctx->demuxer->file_format == DEMUXER_TYPE_MOV) && stream_dump_type == 2) - stream_write_buffer(os, &in_size, 4); + stream_write_buffer(os, (unsigned char *)&in_size, 4); if (in_size > 0) { stream_write_buffer(os, start, in_size); stream_dump_progress(in_size, mpctx->stream); -- 2.25.1 From f64fcbefa296b2e226b42db4f88af21b5f03fe02 Mon Sep 17 00:00:00 2001 From: cigaes Date: Sat, 21 Sep 2024 09:30:06 +0000 Subject: [PATCH] libmpcodecs/vf_scale: explicit pointer casts Recent compilers consider implicit casts an error. git-svn-id: svn://git.mplayerhq.hu/mplayer/trunk@38647 b3059339-0415-0410-9bf9-f77b7e298cf2 --- libmpcodecs/vf_scale.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/libmpcodecs/vf_scale.c b/libmpcodecs/vf_scale.c index e48a2ad45..39deb59c2 100644 --- a/libmpcodecs/vf_scale.c +++ b/libmpcodecs/vf_scale.c @@ -439,14 +439,14 @@ static void scale(struct SwsContext *sws1, struct SwsContext *sws2, uint8_t *src int src_stride2[MP_MAX_PLANES]={2*src_stride[0], 2*src_stride[1], 2*src_stride[2], 2*src_stride[3]}; int dst_stride2[MP_MAX_PLANES]={2*dst_stride[0], 2*dst_stride[1], 2*dst_stride[2], 2*dst_stride[3]}; - sws_scale(sws1, src2, src_stride2, y>>1, h>>1, dst2, dst_stride2); + sws_scale(sws1, (const uint8_t *const *)src2, src_stride2, y>>1, h>>1, dst2, dst_stride2); for(i=0; i>1, h>>1, dst2, dst_stride2); + sws_scale(sws2, (const uint8_t *const *)src2, src_stride2, y>>1, h>>1, dst2, dst_stride2); }else{ - sws_scale(sws1, src2, src_stride, y, h, dst, dst_stride); + sws_scale(sws1, (const uint8_t *const *)src2, src_stride, y, h, dst, dst_stride); } } -- 2.25.1 Patch-Source: https://git.mplayerhq.hu/gitweb/mplayer.git/commit/236a20eae0497c69185b2b832e2a302af4851109 Diff between source and af_lavcresample.c at the commit. -- --- a/libaf/af_lavcresample.c +++ b/libaf/af_lavcresample.c @@ -45,6 +45,7 @@ int phase_shift; double cutoff; + int ctx_format; int ctx_out_rate; int ctx_in_rate; int ctx_filter_size; @@ -57,6 +58,9 @@ // Initialization and runtime control static int control(struct af_instance_s* af, int cmd, void* arg) { + AVChannelLayout ch_layout; + enum AVSampleFormat av_format; + af_resample_t* s = (af_resample_t*)af->setup; af_data_t *data= (af_data_t*)arg; int out_rate, test_output_res; // helpers for checking input format @@ -68,12 +72,23 @@ af->data->nch = data->nch; if (af->data->nch > AF_NCH) af->data->nch = AF_NCH; - af->data->format = AF_FORMAT_S16_NE; - af->data->bps = 2; + if(data->format == AF_FORMAT_FLOAT_NE){ + af->data->format = AF_FORMAT_FLOAT_NE; + av_format = AV_SAMPLE_FMT_FLT; + }else + { + af->data->format = AF_FORMAT_S16_NE; + av_format = AV_SAMPLE_FMT_S16; + } + + af->data->bps = af_fmt2bits(af->data->format)/8; af->mul = (double)af->data->rate / data->rate; af->delay = af->data->nch * s->filter_length / FFMIN(af->mul, 1); // *bps*.5 - if (s->ctx_out_rate != af->data->rate || s->ctx_in_rate != data->rate || s->ctx_filter_size != s->filter_length || + av_channel_layout_default(&ch_layout, af->data->nch); + + if (s->ctx_format != af->data->format || + s->ctx_out_rate != af->data->rate || s->ctx_in_rate != data->rate || s->ctx_filter_size != s->filter_length || s->ctx_phase_shift != s->phase_shift || s->ctx_linear != s->linear || s->ctx_cutoff != s->cutoff) { swr_free(&s->swrctx); if((s->swrctx=swr_alloc()) == NULL) return AF_ERROR; @@ -83,11 +98,13 @@ av_opt_set_int(s->swrctx, "phase_shift", s->phase_shift, 0); av_opt_set_int(s->swrctx, "linear_interp", s->linear, 0); av_opt_set_double(s->swrctx, "cutoff", s->cutoff, 0); - av_opt_set_sample_fmt(s->swrctx, "in_sample_fmt", AV_SAMPLE_FMT_S16, 0); - av_opt_set_sample_fmt(s->swrctx, "out_sample_fmt", AV_SAMPLE_FMT_S16, 0); - av_opt_set_int(s->swrctx, "in_channel_count", af->data->nch, 0); - av_opt_set_int(s->swrctx, "out_channel_count", af->data->nch, 0); + if(av_opt_set_sample_fmt(s->swrctx, "in_sample_fmt", av_format, 0) < 0) return AF_ERROR; + if(av_opt_set_sample_fmt(s->swrctx, "out_sample_fmt", av_format, 0) < 0) return AF_ERROR; + if(av_opt_set_chlayout(s->swrctx, "in_chlayout", &ch_layout, 0) < 0) return AF_ERROR; + if(av_opt_set_chlayout(s->swrctx, "out_chlayout", &ch_layout, 0) < 0) return AF_ERROR; + if(swr_init(s->swrctx) < 0) return AF_ERROR; + s->ctx_format = af->data->format; s->ctx_out_rate = af->data->rate; s->ctx_in_rate = data->rate; s->ctx_filter_size = s->filter_length; @@ -139,6 +156,7 @@ int8_t *out; int chans = data->nch; int in_len = data->len; + int bps = data->bps; int out_len = in_len * af->mul + 10; if(AF_OK != RESIZE_LOCAL_BUFFER(af,data)) @@ -156,9 +174,9 @@ memcpy(s->in[0], in, in_len); - ret = swr_convert(s->swrctx, &s->tmp[0], out_len/chans/2, &s->in[0], in_len/chans/2); + ret = swr_convert(s->swrctx, &s->tmp[0], out_len/chans/bps, (const uint8_t *const *)&s->in[0], in_len/chans/bps); if (ret < 0) return NULL; - out_len= ret*chans*2; + out_len= ret*chans*bps; memcpy(out, s->tmp[0], out_len);