FFmpeg
Loading...
Searching...
No Matches
trim.c File Reference

Go to the source code of this file.

Data Structures

struct  TrimBound
 
struct  TrimContext
 

Macros

#define OFFSET(x)
 
#define FLAGS   (AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_AUDIO_PARAM|AV_OPT_FLAG_BSF_PARAM)
 

Enumerations

enum  TrimType {
  TRIM_PTS , TRIM_DTS , TRIM_PKT_INDEX , TRIM_MSEC_PT ,
  TRIM_MSEC_DT , TRIM_DUR_TS , TRIM_DUR_T_MSEC
}
 
enum  TrimAxis { AXIS_PTS , AXIS_DTS , AXIS_INDEX , AXIS_OUT_INDEX }
 

Functions

static int add_checked (AVBSFContext *ctx, int64_t *acc, int64_t delta, const char *what)
 
static int64_t packet_axis (const TrimContext *s, const AVPacket *pkt, enum TrimAxis axis)
 
static enum TrimAxis monotonic_axis (enum TrimAxis axis)
 
static int axis_is_time (enum TrimAxis axis)
 
static int convert_checked (AVBSFContext *ctx, int64_t *value, AVRational from, AVRational to, const char *what)
 
static int time_base_to_samples (AVBSFContext *ctx, int64_t *value, const char *what)
 
static int samples_to_time_base (AVBSFContext *ctx, int64_t *value, const char *what)
 
static int64_t packet_samples (AVBSFContext *ctx, const AVPacket *pkt)
 
static int64_t packet_skip_consumed (AVBSFContext *ctx, const AVPacket *pkt)
 
static int packet_span (AVBSFContext *ctx, const AVPacket *pkt, enum TrimAxis axis, int64_t *span)
 
static int bound_init (AVBSFContext *ctx, TrimBound *b, int active, int64_t value, int type, int rel, const char *name)
 
static void bound_reset (TrimBound *b)
 
static int bound_resolve (AVBSFContext *ctx, TrimBound *b, int64_t ref, const char *name)
 
static int trim_head (AVBSFContext *ctx, const AVPacket *pkt, int64_t *head)
 
static int trim_tail (AVBSFContext *ctx, const AVPacket *pkt, int64_t head, int64_t *tail)
 
static int trim_audio (AVBSFContext *ctx, AVPacket *pkt, int64_t head, int keep)
 
static int trim_shift (AVBSFContext *ctx, AVPacket *pkt, int64_t head)
 
static void preroll_clear (AVBSFContext *ctx)
 
static void preroll_export (AVBSFContext *ctx, AVPacket *pkt)
 
static int preroll_hold (AVBSFContext *ctx, AVPacket *pkt)
 
static void log_exported_packet (AVBSFContext *ctx, const char *which, int64_t idx, int64_t pts, int64_t dts, int key)
 
static void packet_exported (AVBSFContext *ctx, const AVPacket *pkt)
 
static void trim_report (AVBSFContext *ctx)
 
static int trim_filter (AVBSFContext *ctx, AVPacket *pkt)
 
static void trim_reset (AVBSFContext *ctx)
 
static void trim_flush (AVBSFContext *ctx)
 
static void trim_close (AVBSFContext *ctx)
 
static int trim_init (AVBSFContext *ctx)
 

Variables

struct { 
 
   enum TrimAxis   axis 
 
   int   msec 
 
   int   relative 
 
trim_types [] 
 
static const AVOption trim_options []
 
static const AVClass trim_class
 
const FFBitStreamFilter ff_trim_bsf
 

Macro Definition Documentation

◆ OFFSET

#define OFFSET ( x)
Value:
offsetof(TrimContext, x)

Definition at line 745 of file trim.c.

◆ FLAGS

Definition at line 746 of file trim.c.

Enumeration Type Documentation

◆ TrimType

enum TrimType
Enumerator
TRIM_PTS 
TRIM_DTS 
TRIM_PKT_INDEX 
TRIM_MSEC_PT 
TRIM_MSEC_DT 
TRIM_DUR_TS 
TRIM_DUR_T_MSEC 

Definition at line 27 of file trim.c.

◆ TrimAxis

enum TrimAxis
Enumerator
AXIS_PTS 
AXIS_DTS 
AXIS_INDEX 
AXIS_OUT_INDEX 

Definition at line 39 of file trim.c.

Function Documentation

◆ add_checked()

static int add_checked ( AVBSFContext * ctx,
int64_t * acc,
int64_t delta,
const char * what )
static

Definition at line 108 of file trim.c.

Referenced by bound_resolve(), trim_shift(), and trim_tail().

◆ packet_axis()

static int64_t packet_axis ( const TrimContext * s,
const AVPacket * pkt,
enum TrimAxis axis )
static

Definition at line 122 of file trim.c.

Referenced by trim_head(), and trim_tail().

◆ monotonic_axis()

static enum TrimAxis monotonic_axis ( enum TrimAxis axis)
static

Definition at line 134 of file trim.c.

Referenced by trim_tail().

◆ axis_is_time()

static int axis_is_time ( enum TrimAxis axis)
static

Definition at line 140 of file trim.c.

Referenced by packet_span(), and trim_tail().

◆ convert_checked()

static int convert_checked ( AVBSFContext * ctx,
int64_t * value,
AVRational from,
AVRational to,
const char * what )
static

Definition at line 147 of file trim.c.

Referenced by samples_to_time_base(), and time_base_to_samples().

◆ time_base_to_samples()

static int time_base_to_samples ( AVBSFContext * ctx,
int64_t * value,
const char * what )
static

Definition at line 162 of file trim.c.

Referenced by trim_audio().

◆ samples_to_time_base()

static int samples_to_time_base ( AVBSFContext * ctx,
int64_t * value,
const char * what )
static

Definition at line 169 of file trim.c.

Referenced by packet_span(), and trim_audio().

◆ packet_samples()

static int64_t packet_samples ( AVBSFContext * ctx,
const AVPacket * pkt )
static

Definition at line 177 of file trim.c.

Referenced by flush_silent_frames(), packet_skip_consumed(), packet_span(), and trim_audio().

◆ packet_skip_consumed()

static int64_t packet_skip_consumed ( AVBSFContext * ctx,
const AVPacket * pkt )
static

Definition at line 184 of file trim.c.

Referenced by trim_audio().

◆ packet_span()

static int packet_span ( AVBSFContext * ctx,
const AVPacket * pkt,
enum TrimAxis axis,
int64_t * span )
static

Definition at line 200 of file trim.c.

Referenced by trim_head(), and trim_tail().

◆ bound_init()

static int bound_init ( AVBSFContext * ctx,
TrimBound * b,
int active,
int64_t value,
int type,
int rel,
const char * name )
static

Definition at line 220 of file trim.c.

Referenced by trim_init().

◆ bound_reset()

static void bound_reset ( TrimBound * b)
static

Definition at line 251 of file trim.c.

Referenced by trim_reset().

◆ bound_resolve()

static int bound_resolve ( AVBSFContext * ctx,
TrimBound * b,
int64_t ref,
const char * name )
static

Definition at line 257 of file trim.c.

Referenced by trim_head(), and trim_tail().

◆ trim_head()

static int trim_head ( AVBSFContext * ctx,
const AVPacket * pkt,
int64_t * head )
static

Definition at line 272 of file trim.c.

Referenced by trim_filter().

◆ trim_tail()

static int trim_tail ( AVBSFContext * ctx,
const AVPacket * pkt,
int64_t head,
int64_t * tail )
static

Definition at line 310 of file trim.c.

Referenced by trim_audio(), and trim_shift().

◆ trim_audio()

static int trim_audio ( AVBSFContext * ctx,
AVPacket * pkt,
int64_t head,
int keep )
static

Definition at line 367 of file trim.c.

Referenced by trim_filter().

◆ trim_shift()

static int trim_shift ( AVBSFContext * ctx,
AVPacket * pkt,
int64_t head )
static

Definition at line 475 of file trim.c.

Referenced by trim_filter().

◆ preroll_clear()

static void preroll_clear ( AVBSFContext * ctx)
static

Definition at line 507 of file trim.c.

Referenced by preroll_hold(), trim_close(), trim_filter(), and trim_reset().

◆ preroll_export()

static void preroll_export ( AVBSFContext * ctx,
AVPacket * pkt )
static

Definition at line 518 of file trim.c.

Referenced by trim_filter().

◆ preroll_hold()

static int preroll_hold ( AVBSFContext * ctx,
AVPacket * pkt )
static

Definition at line 534 of file trim.c.

Referenced by trim_filter().

◆ log_exported_packet()

static void log_exported_packet ( AVBSFContext * ctx,
const char * which,
int64_t idx,
int64_t pts,
int64_t dts,
int key )
static

Definition at line 566 of file trim.c.

Referenced by packet_exported(), and trim_report().

◆ packet_exported()

static void packet_exported ( AVBSFContext * ctx,
const AVPacket * pkt )
static

Definition at line 574 of file trim.c.

Referenced by trim_filter().

◆ trim_report()

static void trim_report ( AVBSFContext * ctx)
static

Definition at line 588 of file trim.c.

Referenced by trim_close(), and trim_flush().

◆ trim_filter()

static int trim_filter ( AVBSFContext * ctx,
AVPacket * pkt )
static

Definition at line 600 of file trim.c.

◆ trim_reset()

static void trim_reset ( AVBSFContext * ctx)
static

Definition at line 658 of file trim.c.

Referenced by trim_flush(), and trim_init().

◆ trim_flush()

static void trim_flush ( AVBSFContext * ctx)
static

Definition at line 676 of file trim.c.

◆ trim_close()

static void trim_close ( AVBSFContext * ctx)
static

Definition at line 682 of file trim.c.

◆ trim_init()

static int trim_init ( AVBSFContext * ctx)
static

Definition at line 692 of file trim.c.

Variable Documentation

◆ axis

◆ msec

int msec

Definition at line 50 of file trim.c.

Referenced by bound_init(), and read_header().

◆ relative

◆ [struct]

const struct { ... } trim_types[]
Initial value:
= {
[TRIM_PTS] = { AXIS_PTS, 0, 0 },
[TRIM_DTS] = { AXIS_DTS, 0, 0 },
[TRIM_PKT_INDEX] = { AXIS_INDEX, 0, 0 },
[TRIM_MSEC_PT] = { AXIS_PTS, 1, 0 },
[TRIM_MSEC_DT] = { AXIS_DTS, 1, 0 },
[TRIM_DUR_TS] = { AXIS_PTS, 0, 1 },
[TRIM_DUR_T_MSEC] = { AXIS_PTS, 1, 1 },
}
@ AXIS_PTS
Definition trim.c:40
@ AXIS_DTS
Definition trim.c:41
@ AXIS_INDEX
Definition trim.c:42
@ TRIM_DUR_T_MSEC
Definition trim.c:34
@ TRIM_DUR_TS
Definition trim.c:33
@ TRIM_MSEC_PT
Definition trim.c:31
@ TRIM_PTS
Definition trim.c:28
@ TRIM_MSEC_DT
Definition trim.c:32
@ TRIM_PKT_INDEX
Definition trim.c:30
@ TRIM_DTS
Definition trim.c:29

Referenced by bound_init().

◆ trim_options

const AVOption trim_options[]
static

Definition at line 747 of file trim.c.

◆ trim_class

const AVClass trim_class
static
Initial value:
= {
.class_name = "trim",
.item_name = av_default_item_name,
.option = trim_options,
}
const char * av_default_item_name(void *ptr)
Return the context name.
Definition log.c:241
#define LIBAVUTIL_VERSION_INT
Definition version.h:85
static const AVOption trim_options[]
Definition trim.c:747

Definition at line 783 of file trim.c.

◆ ff_trim_bsf

const FFBitStreamFilter ff_trim_bsf
Initial value:
= {
.p.name = "trim",
.p.priv_class = &trim_class,
.priv_data_size = sizeof(TrimContext),
}
static av_cold void close(AVCodecParserContext *s)
Definition apv_parser.c:197
void(* flush)(AVBSFContext *ctx)
Definition dts2pts.c:610
int(* init)(AVBSFContext *ctx)
Definition dts2pts.c:608
static void trim_close(AVBSFContext *ctx)
Definition trim.c:682
static void trim_flush(AVBSFContext *ctx)
Definition trim.c:676
static const AVClass trim_class
Definition trim.c:783
static int trim_filter(AVBSFContext *ctx, AVPacket *pkt)
Definition trim.c:600
static int trim_init(AVBSFContext *ctx)
Definition trim.c:692
void(* filter)(uint8_t *src, ptrdiff_t stride, int qscale)
Definition h263dsp.c:29

Definition at line 790 of file trim.c.