Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
FFmpeg
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
libremedia
Tethys
FFmpeg
Commits
e8b62df6
Commit
e8b62df6
authored
22 years ago
by
Michael Niedermayer
Browse files
Options
Downloads
Patches
Plain Diff
fixing apiexample
Originally committed as revision 958 to
svn://svn.ffmpeg.org/ffmpeg/trunk
parent
b71901e6
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
libavcodec/apiexample.c
+15
-15
15 additions, 15 deletions
libavcodec/apiexample.c
libavcodec/utils.c
+7
-0
7 additions, 0 deletions
libavcodec/utils.c
with
22 additions
and
15 deletions
libavcodec/apiexample.c
+
15
−
15
View file @
e8b62df6
...
@@ -19,7 +19,7 @@
...
@@ -19,7 +19,7 @@
void
audio_encode_example
(
const
char
*
filename
)
void
audio_encode_example
(
const
char
*
filename
)
{
{
AVCodec
*
codec
;
AVCodec
*
codec
;
AVCodecContext
codec_context
,
*
c
=
&
codec_context
;
AVCodecContext
*
c
=
NULL
;
int
frame_size
,
i
,
j
,
out_size
,
outbuf_size
;
int
frame_size
,
i
,
j
,
out_size
,
outbuf_size
;
FILE
*
f
;
FILE
*
f
;
short
*
samples
;
short
*
samples
;
...
@@ -35,9 +35,8 @@ void audio_encode_example(const char *filename)
...
@@ -35,9 +35,8 @@ void audio_encode_example(const char *filename)
exit
(
1
);
exit
(
1
);
}
}
/* put default values */
c
=
avcodec_alloc_context
();
memset
(
c
,
0
,
sizeof
(
*
c
));
/* put sample parameters */
/* put sample parameters */
c
->
bit_rate
=
64000
;
c
->
bit_rate
=
64000
;
c
->
sample_rate
=
44100
;
c
->
sample_rate
=
44100
;
...
@@ -79,6 +78,7 @@ void audio_encode_example(const char *filename)
...
@@ -79,6 +78,7 @@ void audio_encode_example(const char *filename)
free
(
samples
);
free
(
samples
);
avcodec_close
(
c
);
avcodec_close
(
c
);
free
(
c
);
}
}
/*
/*
...
@@ -87,7 +87,7 @@ void audio_encode_example(const char *filename)
...
@@ -87,7 +87,7 @@ void audio_encode_example(const char *filename)
void
audio_decode_example
(
const
char
*
outfilename
,
const
char
*
filename
)
void
audio_decode_example
(
const
char
*
outfilename
,
const
char
*
filename
)
{
{
AVCodec
*
codec
;
AVCodec
*
codec
;
AVCodecContext
codec_context
,
*
c
=
&
codec_context
;
AVCodecContext
*
c
=
NULL
;
int
out_size
,
size
,
len
;
int
out_size
,
size
,
len
;
FILE
*
f
,
*
outfile
;
FILE
*
f
,
*
outfile
;
UINT8
*
outbuf
;
UINT8
*
outbuf
;
...
@@ -102,8 +102,7 @@ void audio_decode_example(const char *outfilename, const char *filename)
...
@@ -102,8 +102,7 @@ void audio_decode_example(const char *outfilename, const char *filename)
exit
(
1
);
exit
(
1
);
}
}
/* put default values */
c
=
avcodec_alloc_context
();
memset
(
c
,
0
,
sizeof
(
*
c
));
/* open it */
/* open it */
if
(
avcodec_open
(
c
,
codec
)
<
0
)
{
if
(
avcodec_open
(
c
,
codec
)
<
0
)
{
...
@@ -120,7 +119,7 @@ void audio_decode_example(const char *outfilename, const char *filename)
...
@@ -120,7 +119,7 @@ void audio_decode_example(const char *outfilename, const char *filename)
}
}
outfile
=
fopen
(
outfilename
,
"w"
);
outfile
=
fopen
(
outfilename
,
"w"
);
if
(
!
outfile
)
{
if
(
!
outfile
)
{
f
printf
(
stderr
,
"could not open %s
\n
"
,
outfilename
);
f
ree
(
c
);
exit
(
1
);
exit
(
1
);
}
}
...
@@ -153,6 +152,7 @@ void audio_decode_example(const char *outfilename, const char *filename)
...
@@ -153,6 +152,7 @@ void audio_decode_example(const char *outfilename, const char *filename)
free
(
outbuf
);
free
(
outbuf
);
avcodec_close
(
c
);
avcodec_close
(
c
);
free
(
c
);
}
}
/*
/*
...
@@ -161,7 +161,7 @@ void audio_decode_example(const char *outfilename, const char *filename)
...
@@ -161,7 +161,7 @@ void audio_decode_example(const char *outfilename, const char *filename)
void
video_encode_example
(
const
char
*
filename
)
void
video_encode_example
(
const
char
*
filename
)
{
{
AVCodec
*
codec
;
AVCodec
*
codec
;
AVCodecContext
codec_context
,
*
c
=
&
codec_context
;
AVCodecContext
*
c
=
NULL
;
int
i
,
out_size
,
size
,
x
,
y
,
outbuf_size
;
int
i
,
out_size
,
size
,
x
,
y
,
outbuf_size
;
FILE
*
f
;
FILE
*
f
;
AVPicture
picture
;
AVPicture
picture
;
...
@@ -176,9 +176,8 @@ void video_encode_example(const char *filename)
...
@@ -176,9 +176,8 @@ void video_encode_example(const char *filename)
exit
(
1
);
exit
(
1
);
}
}
/* put default values */
c
=
avcodec_alloc_context
();
memset
(
c
,
0
,
sizeof
(
*
c
));
/* put sample parameters */
/* put sample parameters */
c
->
bit_rate
=
400000
;
c
->
bit_rate
=
400000
;
/* resolution must be a multiple of two */
/* resolution must be a multiple of two */
...
@@ -251,6 +250,7 @@ void video_encode_example(const char *filename)
...
@@ -251,6 +250,7 @@ void video_encode_example(const char *filename)
free
(
outbuf
);
free
(
outbuf
);
avcodec_close
(
c
);
avcodec_close
(
c
);
free
(
c
);
printf
(
"
\n
"
);
printf
(
"
\n
"
);
}
}
...
@@ -273,7 +273,7 @@ void pgm_save(unsigned char *buf,int wrap, int xsize,int ysize,char *filename)
...
@@ -273,7 +273,7 @@ void pgm_save(unsigned char *buf,int wrap, int xsize,int ysize,char *filename)
void
video_decode_example
(
const
char
*
outfilename
,
const
char
*
filename
)
void
video_decode_example
(
const
char
*
outfilename
,
const
char
*
filename
)
{
{
AVCodec
*
codec
;
AVCodec
*
codec
;
AVCodecContext
codec_context
,
*
c
=
&
codec_context
;
AVCodecContext
*
c
=
NULL
;
int
frame
,
size
,
got_picture
,
len
;
int
frame
,
size
,
got_picture
,
len
;
FILE
*
f
;
FILE
*
f
;
AVPicture
picture
;
AVPicture
picture
;
...
@@ -289,8 +289,7 @@ void video_decode_example(const char *outfilename, const char *filename)
...
@@ -289,8 +289,7 @@ void video_decode_example(const char *outfilename, const char *filename)
exit
(
1
);
exit
(
1
);
}
}
/* put default values */
c
=
avcodec_alloc_context
();
memset
(
c
,
0
,
sizeof
(
*
c
));
/* for some codecs, such as msmpeg4 and mpeg4, width and height
/* for some codecs, such as msmpeg4 and mpeg4, width and height
MUST be initialized there because these info are not available
MUST be initialized there because these info are not available
...
@@ -375,6 +374,7 @@ void video_decode_example(const char *outfilename, const char *filename)
...
@@ -375,6 +374,7 @@ void video_decode_example(const char *outfilename, const char *filename)
fclose
(
f
);
fclose
(
f
);
avcodec_close
(
c
);
avcodec_close
(
c
);
free
(
c
);
printf
(
"
\n
"
);
printf
(
"
\n
"
);
}
}
...
...
This diff is collapsed.
Click to expand it.
libavcodec/utils.c
+
7
−
0
View file @
e8b62df6
...
@@ -50,10 +50,17 @@ void register_avcodec(AVCodec *format)
...
@@ -50,10 +50,17 @@ void register_avcodec(AVCodec *format)
}
}
void
avcodec_get_context_defaults
(
AVCodecContext
*
s
){
void
avcodec_get_context_defaults
(
AVCodecContext
*
s
){
s
->
bit_rate
=
800
*
1000
;
s
->
bit_rate_tolerance
=
s
->
bit_rate
*
10
;
s
->
qmin
=
2
;
s
->
qmin
=
2
;
s
->
qmax
=
31
;
s
->
qmax
=
31
;
s
->
rc_eq
=
"tex^qComp"
;
s
->
rc_eq
=
"tex^qComp"
;
s
->
qcompress
=
0
.
5
;
s
->
qcompress
=
0
.
5
;
s
->
max_qdiff
=
3
;
s
->
b_quant_factor
=
1
.
25
;
s
->
b_quant_offset
=
1
.
25
;
s
->
i_quant_factor
=
0
.
8
;
s
->
i_quant_offset
=
0
.
0
;
}
}
/**
/**
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment