[FFmpeg-user] Filter documentation -- PTSs

Chris Angelico rosuav at gmail.com
Mon Feb 15 08:56:39 EET 2021


On Mon, Feb 15, 2021 at 5:32 PM Mark Filipak (ffmpeg)
<markfilipak at bog.us> wrote:
> > frame->pts = (
> >       (s->start_time == AV_NOPTS_VALUE) ? 0 : s->start_time) +
> >       av_rescale(outlink->frame_count_in, s->ts_unit.num, s->ts_unit.den);
>
> I don't know what this: 'frame->pts', means. I have written a ton of assembly code for various
> micros and people tell me, "It's easy, Mark. 'frame->pts' is a 'pointer' to memory as in assembly",
> but I don't see the analog of a memory address register in it. If 'pts' is a pointer, then how can
> 'frame' be written through that pointer and where does it get written? It's a mystery to me. Or is
> 'frame' the pointer and 'pts' the memory location?

'frame' is a pointer to a structure of some sort, and 'pts' is a named
element within that structure. So you might have something like:

struct FrameyThingyWhatsit {
    int foo;
    int bar;
    void *quux;
    int pts;
    const char *flurble;
};

and then 'frame' would be a pointer to an in-memory structure of that
type. When you refer to 'frame->pts', that means 'look at the spot in
memory three words in from where frame points, and assign to that'.

But I think Carl's point was that you can't simply look at an
expression and decode it as algebra. To understand this line of code,
you not only have to interpret the syntax of this exact line, but -
and probably more importantly - you have to understand what the
av_rescale function is doing.

> It's my deficiency, but it stops me cold every time I look at 'C' code. My brain just locks up.

Yeah, well, I generally recommend spending as little time in C as
possible, if you want to be productive :) I like to pick up a library
like ffmpeg, and then write all the surrounding code in a high level
language like Python or Pike. The "heavy lifting" is done by the
library, but I spend 99% of my time working in high level code,
figuring out what I actually want my app to be doing.

ChrisA


More information about the ffmpeg-user mailing list