[FFmpeg-user] Filter documentation -- PTSs

Chris Angelico rosuav at gmail.com
Tue Feb 16 01:47:02 EET 2021


On Tue, Feb 16, 2021 at 8:44 AM Mark Filipak (ffmpeg)
<markfilipak at bog.us> wrote:
>
> On 02/15/2021 04:32 PM, Carl Zwanzig wrote:
> > On 2/15/2021 1:26 PM, Mark Filipak (ffmpeg) wrote:
> >> Yes, I'm aware of C++. It's sort of a 'C' language architecture hack, isn't it?
> > More like butchery ...
>
> Ooooo... that's harsh.  :-)
>
> > Glad it's making more sense now.
> >
> > z!
>
> Thanks for the confirmation. Now, regarding pointers-to-pointers and '*' as a unary operator.....
>

A pointer, at its core, is a number representing a place in memory. A
pointer to a pointer is a number representing the place in memory
where you can find another number that'll tell you where you want to
go. You want to know where the Sword Master can be found, but I won't
tell you where he is; all I'll tell you is that the shopkeeper knows
where to find the Sword Master. I point you to the shopkeeper, and
then you ask him to point you to the Sword Master.

The asterisk, as a unary operator, is one step in that process.
Something like this:

int **trial = find_sword_master();

"trial" is a number that says where in memory the shopkeeper is.
What's that number?

printf("Shopkeeper is at %p\n", trial);

"*trial" is the number that can be found there. What's that number?

printf("Sword Master is at %p\n", *trial);

The number you found when you asked the shopkeeper is the address of
the Sword Master. So if you want to actually learn what the sword
master can teach you, you'd have to go to that address.

printf("Sword Master can teach you: %d\n", *(*trial));

and since the parentheses do nothing there, that's just the same as "**trial".

The unary asterisk is the technique of following a pointer to find out
what it points to, and you can do it more than once.

There's a lot of monkeying around in C, but most of it comes down to a
few simple operations, done lots and lots of times. So if you're stuck
thinking there are no clever tricks that could help you, don't worry -
there are, you just might have never learned them. And that's a
solvable problem.

ChrisA
(I post like a dairy farmer.)


More information about the ffmpeg-user mailing list