File tree Expand file tree Collapse file tree 3 files changed +12
-2
lines changed Expand file tree Collapse file tree 3 files changed +12
-2
lines changed Original file line number Diff line number Diff line change @@ -312,8 +312,10 @@ void BetaCudaDeviceInterface::applyBSF(ReferenceAVPacket& packet) {
312312 // fields of the filtered packet into the original packet. The filtered packet
313313 // fields are re-set by av_packet_move_ref, so when it goes out of scope and
314314 // gets destructed, it's not going to affect the original packet.
315- av_packet_unref (packet.get ());
316- av_packet_move_ref (packet.get (), filteredPacket.get ());
315+ packet.reset (filteredPacket);
316+ // TODONVDEC P0: consider cleaner ways to do this. Maybe we should let
317+ // applyBSF return a new packet, and maybe that new packet needs to be a field
318+ // on the interface to avoid complex lifetime issues.
317319}
318320
319321// Parser triggers this callback within cuvidParseVideoData when a frame is
Original file line number Diff line number Diff line change @@ -33,6 +33,13 @@ AVPacket* ReferenceAVPacket::operator->() {
3333 return avPacket_;
3434}
3535
36+ void ReferenceAVPacket::reset (ReferenceAVPacket& other) {
37+ if (this != &other) {
38+ av_packet_unref (avPacket_);
39+ av_packet_move_ref (avPacket_, other.avPacket_ );
40+ }
41+ }
42+
3643AVCodecOnlyUseForCallingAVFindBestStream
3744makeAVCodecOnlyUseForCallingAVFindBestStream (const AVCodec* codec) {
3845#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(59, 18, 100)
Original file line number Diff line number Diff line change @@ -135,6 +135,7 @@ class ReferenceAVPacket {
135135 ~ReferenceAVPacket ();
136136 AVPacket* get ();
137137 AVPacket* operator ->();
138+ void reset (ReferenceAVPacket& other);
138139};
139140
140141// av_find_best_stream is not const-correct before commit:
You can’t perform that action at this time.
0 commit comments