refactor: cleanup unused functions

This commit is contained in:
Adrian Shum 2022-10-16 12:34:57 +08:00
parent 7367cc4750
commit 941ceaed31
3 changed files with 0 additions and 23 deletions

View file

@ -257,30 +257,11 @@ obtain_next_frame(AVFormatContext *fmt_ctx, AVCodecContext *dec_ctx, int stream_
return err; return err;
} }
int64_t find_duration(AVFormatContext *fmt_ctx) {
AVPacket pkt = create_packet();
int err = 0;
int64_t duration = 0;
while (err >= 0) {
err = av_read_frame(fmt_ctx, &pkt);
if (pkt.pts != AV_NOPTS_VALUE) {
AVRational time_base = fmt_ctx->streams[pkt.stream_index]->time_base;
duration = FFMAX(duration, pkt.pts * 1000000000 * time_base.num / time_base.den);
}
av_packet_unref(&pkt);
}
if (err == AVERROR_EOF) {
return duration;
}
return err;
}
ThumbContext *create_thumb_context(AVStream *stream, AVFrame *frame) { ThumbContext *create_thumb_context(AVStream *stream, AVFrame *frame) {
ThumbContext *thumb_ctx = av_mallocz(sizeof *thumb_ctx); ThumbContext *thumb_ctx = av_mallocz(sizeof *thumb_ctx);
if (!thumb_ctx) { if (!thumb_ctx) {
return thumb_ctx; return thumb_ctx;
} }
// thumb_ctx->n = 0;
thumb_ctx->desc = av_pix_fmt_desc_get(frame->format); thumb_ctx->desc = av_pix_fmt_desc_get(frame->format);
int nb_frames = 100; int nb_frames = 100;
if (stream->disposition & AV_DISPOSITION_ATTACHED_PIC) { if (stream->disposition & AV_DISPOSITION_ATTACHED_PIC) {

View file

@ -6,7 +6,6 @@ package ffmpeg
// #include "ffmpeg.h" // #include "ffmpeg.h"
import "C" import "C"
import ( import (
"context"
"github.com/cshum/imagor/vips/pointer" "github.com/cshum/imagor/vips/pointer"
"io" "io"
"math" "math"
@ -35,7 +34,6 @@ type Metadata struct {
} }
type AVContext struct { type AVContext struct {
context context.Context
opaque unsafe.Pointer opaque unsafe.Pointer
reader io.Reader reader io.Reader
seeker io.Seeker seeker io.Seeker

View file

@ -52,8 +52,6 @@ AVPacket create_packet();
int int
obtain_next_frame(AVFormatContext *fmt_ctx, AVCodecContext *dec_ctx, int stream_index, AVPacket *pkt, AVFrame **frame); obtain_next_frame(AVFormatContext *fmt_ctx, AVCodecContext *dec_ctx, int stream_index, AVPacket *pkt, AVFrame **frame);
int64_t find_duration(AVFormatContext *fmt_ctx);
ThumbContext *create_thumb_context(AVStream *stream, AVFrame *frame); ThumbContext *create_thumb_context(AVStream *stream, AVFrame *frame);
void free_thumb_context(ThumbContext *thumb_ctx); void free_thumb_context(ThumbContext *thumb_ctx);