int AudioEncode::encode(AVPacket * pkt, const uint8_t ** data, int nb_samples) { if (mBitRate == 0) mBitRate = defaultBitRate(); if (mChannelLayout == 0) { mChannelLayout = defaultChannelLayout(); } else { mChannelLayout = checkChannelLayout(mChannelLayout); } if (mSampleFmt == AV_SAMPLE_FMT_NONE) { mSampleFmt = defaultSampleFmt(); } else { mSampleFmt = checkSampleFmt(mSampleFmt); } if (mSampleRate == 0) mSampleRate = defaultSampleRate(); mCodecCtx->bit_rate = mBitRate; mCodecCtx->channel_layout = mChannelLayout; mCodecCtx->sample_fmt = mSampleFmt; mCodecCtx->sample_rate = mSampleRate; mCodecCtx->flags |= mFlags; if (!avcodec_is_open(mCodecCtx)) { avcodec_open2(mCodecCtx, mCodec, NULL); } mState = ENCODE_STATE_RUN; return doEncode(pkt, data, nb_samples); }
Encode_Status VaapiEncoderBase::encode(const SharedPtr<VideoFrame>& frame) { if (!frame || !frame->surface) return ENCODE_INVALID_PARAMS; if (isBusy()) return ENCODE_IS_BUSY; SurfacePtr surface = createSurface(frame); if (!surface) return ENCODE_INVALID_PARAMS; return doEncode(surface, frame->timeStamp, frame->flags & VIDEO_FRAME_FLAGS_KEY); }
Encode_Status VaapiEncoderBase::encode(VideoFrameRawData* frame) { if (!frame || !frame->width || !frame->height || !frame->fourcc) return ENCODE_INVALID_PARAMS; FUNC_ENTER(); if (isBusy()) return ENCODE_IS_BUSY; SurfacePtr surface = createSurface(frame); if (!surface) return ENCODE_NO_MEMORY; return doEncode(surface, frame->timeStamp, frame->flags & VIDEO_FRAME_FLAGS_KEY); }
void CRLC<T>::Encode(CImage<T> * pImg, CBitstream * pBstr) { m_timer.start(); doEncode(pImg, pBstr); m_timer.stop(); }