fprintf(stderr, "%s: Cannot fill codec parameters\n", pathname.c_str());
return nullptr;
}
- AVCodec *codec = avcodec_find_decoder(codecpar->codec_id);
+ const AVCodec *codec = avcodec_find_decoder(codecpar->codec_id);
if (codec == nullptr) {
fprintf(stderr, "%s: Cannot find decoder\n", pathname.c_str());
return nullptr;
AVFrameWithDeleter frame = av_frame_alloc_unique();
bool eof = false;
do {
- AVPacket pkt;
- unique_ptr<AVPacket, decltype(av_packet_unref)*> pkt_cleanup(
- &pkt, av_packet_unref);
- av_init_packet(&pkt);
- pkt.data = nullptr;
- pkt.size = 0;
- if (av_read_frame(format_ctx.get(), &pkt) == 0) {
- if (pkt.stream_index != stream_index) {
+ AVPacketWithDeleter pkt = av_packet_alloc_unique();
+ pkt->data = nullptr;
+ pkt->size = 0;
+ if (av_read_frame(format_ctx.get(), pkt.get()) == 0) {
+ if (pkt->stream_index != stream_index) {
continue;
}
- if (avcodec_send_packet(codec_ctx.get(), &pkt) < 0) {
+ if (avcodec_send_packet(codec_ctx.get(), pkt.get()) < 0) {
fprintf(stderr, "%s: Cannot send packet to codec.\n", pathname.c_str());
return nullptr;
}
glBindTexture(GL_TEXTURE_2D, 0);
check_error();
- shared_ptr<Image> image(new Image{unsigned(frame->width), unsigned(frame->height), RefCountedTexture(new GLuint(tex)), last_modified});
+ shared_ptr<Image> image(new Image{unsigned(frame->width), unsigned(frame->height), UniqueTexture(new GLuint(tex)), last_modified});
return image;
}