Skip to content

Commit

Permalink
Revert "refactor(framework): add codec id for packet"
Browse files Browse the repository at this point in the history
This reverts commit 8c21c19.
  • Loading branch information
pingkai committed Mar 18, 2020
1 parent 8713fc5 commit 4e02b04
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 16 deletions.
3 changes: 0 additions & 3 deletions framework/base/media/IAFPacket.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
#include <vector>
#include <memory>
#include <utils/frame_work_log.h>
#include <utils/AFMediaType.h>
#include <cstring>

extern "C" {
Expand Down Expand Up @@ -44,8 +43,6 @@ class CICADA_CPLUS_EXTERN IAFPacket {
uint8_t *extra_data;
int extra_data_size;

AFCodecID codec_id;

void dump();

~packetInfo()
Expand Down
3 changes: 2 additions & 1 deletion framework/codec/ActiveDecoder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ int ActiveDecoder::open(const Stream_meta *meta, void *voutObsr, uint64_t flags)
}

mRunning = true;
mCodecId = meta->codec;
#if AF_HAVE_PTHREAD
auto func = [this]() -> int { return this->decode_func(); };
mDecodeThread = new afThread(func, LOG_TAG);
Expand Down Expand Up @@ -156,7 +157,7 @@ bool ActiveDecoder::needDrop(IAFPacket *packet)
}

// TODO: make sure HEVC not need drop also
if (packet->getInfo().codec_id != AF_CODEC_ID_HEVC) {
if (mCodecId != AF_CODEC_ID_HEVC) {
return false;
}

Expand Down
1 change: 1 addition & 0 deletions framework/codec/ActiveDecoder.h
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ class ActiveDecoder : public Cicada::IDecoder {
#endif
bool bHolding = false;
std::queue<std::unique_ptr<IAFPacket>> mHoldingQueue{};
enum AFCodecID mCodecId{AF_CODEC_ID_NONE};

};

Expand Down
13 changes: 2 additions & 11 deletions framework/demuxer/avFormatDemuxer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -299,11 +299,11 @@ namespace Cicada {
const uint8_t *new_extradata = av_packet_get_side_data(pkt,
AV_PKT_DATA_NEW_EXTRADATA,
&new_extradata_size);
int streamIndex = pkt->stream_index;
AVCodecParameters *codecpar = mCtx->streams[streamIndex]->codecpar;

if (new_extradata) {
AF_LOGI("AV_PKT_DATA_NEW_EXTRADATA");
int streamIndex = pkt->stream_index;
AVCodecParameters *codecpar = mCtx->streams[streamIndex]->codecpar;
av_free(codecpar->extradata);
codecpar->extradata = static_cast<uint8_t *>(av_malloc(new_extradata_size + AV_INPUT_BUFFER_PADDING_SIZE));
memcpy(codecpar->extradata, new_extradata, new_extradata_size);
Expand Down Expand Up @@ -350,16 +350,8 @@ namespace Cicada {

if (needUpdateExtraData) {
packet->setExtraData(new_extradata, new_extradata_size);
} else if (!bFillExtraData && (nullptr == packet->getInfo().extra_data) && (nullptr != codecpar->extradata)) {
packet->setExtraData(codecpar->extradata, codecpar->extradata_size);
}

if (packet->getInfo().extra_data) {
bFillExtraData = true;
}

packet->getInfo().codec_id = AVCodec2CicadaCodec(codecpar->codec_id);

if (packet->getInfo().pts != INT64_MIN) {
packet->getInfo().timePosition = packet->getInfo().pts - mCtx->start_time;
}
Expand Down Expand Up @@ -554,7 +546,6 @@ namespace Cicada {
mPthread->stop();
}

bFillExtraData = false;
#endif
}

Expand Down
1 change: 0 additions & 1 deletion framework/demuxer/avFormatDemuxer.h
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,6 @@ namespace Cicada {
std::map<int, std::unique_ptr<AVStreamCtx>> mStreamCtxMap{};
AVIOContext *mPInPutPb = nullptr;
bool bOpened{false};
bool bFillExtraData{false};
int64_t mStartTime = INT64_MIN;
std::deque<unique_ptr<IAFPacket>> mPacketQueue{};
std::atomic_bool bEOS{false};
Expand Down

0 comments on commit 4e02b04

Please sign in to comment.