| 38 | int32_t InSampleRate, int32_t LogOffset) { |
| 39 | MEMINST_CHECK(MemInst, Frame, 0); |
| 40 | MEM_PTR_CHECK(SwrCtxId, MemInst, uint32_t, SwrCtxPtr, "") |
| 41 | FFMPEG_PTR_FETCH(CurrSwrCtx, *SwrCtxId, SwrContext); |
| 42 | FFMPEG_PTR_FETCH(ExistSWRContext, SWRContextId, SwrContext); |
| 43 | |
| 44 | uint64_t const OutChLayout = |
| 45 | FFmpegUtils::ChannelLayout::fromChannelLayoutID(OutChLayoutId); |
| 46 | AVSampleFormat const OutSampleFmt = |
| 47 | FFmpegUtils::SampleFmt::fromSampleID(OutSampleFmtId); |
| 48 | uint64_t const InChLayout = |
| 49 | FFmpegUtils::ChannelLayout::fromChannelLayoutID(InChLayoutId); |
| 50 | AVSampleFormat const InSampleFmt = |
| 51 | FFmpegUtils::SampleFmt::fromSampleID(InSampleFmtId); |
| 52 | |
| 53 | AVChannelLayout AVOutChLayout; |
| 54 | av_channel_layout_from_mask(&AVOutChLayout, OutChLayout); |
| 55 | |
| 56 | AVChannelLayout AVInChLayout; |
| 57 | av_channel_layout_from_mask(&AVInChLayout, InChLayout); |
| 58 | |
| 59 | swr_alloc_set_opts2(&ExistSWRContext, &AVOutChLayout, OutSampleFmt, |
| 60 | OutSampleRate, &AVInChLayout, InSampleFmt, InSampleRate, |
| 61 | LogOffset, |
| 62 | nullptr); // Always being used as null in rust sdk. |
| 63 | CurrSwrCtx = ExistSWRContext; |
| 64 | |
| 65 | av_channel_layout_uninit(&AVOutChLayout); |
| 66 | av_channel_layout_uninit(&AVInChLayout); |
| 67 | |
| 68 | FFMPEG_PTR_STORE(CurrSwrCtx, SwrCtxId); |
| 69 | return static_cast<int32_t>(ErrNo::Success); |
| 70 | } |
| 71 | |
| 72 | Expect<int32_t> AVOptSetDict::body(const Runtime::CallingFrame &, |
| 73 | uint32_t SWRContextId, uint32_t DictId) { |
| 74 | FFMPEG_PTR_FETCH(SWRContext, SWRContextId, SwrContext); |
| 75 | FFMPEG_PTR_FETCH(AvDictionary, DictId, AVDictionary *); |
| 76 | return av_opt_set_dict(SWRContext, AvDictionary); |
| 77 | } |
| 78 | |
| 79 | Expect<int32_t> SWRConvertFrame::body(const Runtime::CallingFrame &, |
| 80 | uint32_t SWRContextId, |
nothing calls this directly
no outgoing calls
no test coverage detected