Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
F
ffmpeg
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
ffmpeg
Commits
1987a940
Commit
1987a940
authored
Feb 16, 2012
by
Justin Ruggles
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
libgsmenc: use AVCodec.encode2()
parent
d1afb2f9
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
24 additions
and
10 deletions
+24
-10
libgsm.c
libavcodec/libgsm.c
+24
-10
No files found.
libavcodec/libgsm.c
View file @
1987a940
...
@@ -30,6 +30,7 @@
...
@@ -30,6 +30,7 @@
#include <gsm/gsm.h>
#include <gsm/gsm.h>
#include "avcodec.h"
#include "avcodec.h"
#include "internal.h"
#include "gsm.h"
#include "gsm.h"
static
av_cold
int
libgsm_encode_init
(
AVCodecContext
*
avctx
)
{
static
av_cold
int
libgsm_encode_init
(
AVCodecContext
*
avctx
)
{
...
@@ -69,36 +70,49 @@ static av_cold int libgsm_encode_init(AVCodecContext *avctx) {
...
@@ -69,36 +70,49 @@ static av_cold int libgsm_encode_init(AVCodecContext *avctx) {
}
}
}
}
#if FF_API_OLD_ENCODE_AUDIO
avctx
->
coded_frame
=
avcodec_alloc_frame
();
avctx
->
coded_frame
=
avcodec_alloc_frame
();
if
(
!
avctx
->
coded_frame
)
{
if
(
!
avctx
->
coded_frame
)
{
gsm_destroy
(
avctx
->
priv_data
);
gsm_destroy
(
avctx
->
priv_data
);
return
AVERROR
(
ENOMEM
);
return
AVERROR
(
ENOMEM
);
}
}
#endif
return
0
;
return
0
;
}
}
static
av_cold
int
libgsm_encode_close
(
AVCodecContext
*
avctx
)
{
static
av_cold
int
libgsm_encode_close
(
AVCodecContext
*
avctx
)
{
#if FF_API_OLD_ENCODE_AUDIO
av_freep
(
&
avctx
->
coded_frame
);
av_freep
(
&
avctx
->
coded_frame
);
#endif
gsm_destroy
(
avctx
->
priv_data
);
gsm_destroy
(
avctx
->
priv_data
);
avctx
->
priv_data
=
NULL
;
avctx
->
priv_data
=
NULL
;
return
0
;
return
0
;
}
}
static
int
libgsm_encode_frame
(
AVCodecContext
*
avctx
,
static
int
libgsm_encode_frame
(
AVCodecContext
*
avctx
,
AVPacket
*
avpkt
,
unsigned
char
*
frame
,
int
buf_size
,
void
*
data
)
{
const
AVFrame
*
frame
,
int
*
got_packet_ptr
)
// we need a full block
{
if
(
buf_size
<
avctx
->
block_align
)
return
0
;
int
ret
;
gsm_signal
*
samples
=
(
gsm_signal
*
)
frame
->
data
[
0
];
struct
gsm_state
*
state
=
avctx
->
priv_data
;
if
((
ret
=
ff_alloc_packet
(
avpkt
,
avctx
->
block_align
)))
{
av_log
(
avctx
,
AV_LOG_ERROR
,
"Error getting output packet
\n
"
);
return
ret
;
}
switch
(
avctx
->
codec_id
)
{
switch
(
avctx
->
codec_id
)
{
case
CODEC_ID_GSM
:
case
CODEC_ID_GSM
:
gsm_encode
(
avctx
->
priv_data
,
data
,
frame
);
gsm_encode
(
state
,
samples
,
avpkt
->
data
);
break
;
break
;
case
CODEC_ID_GSM_MS
:
case
CODEC_ID_GSM_MS
:
gsm_encode
(
avctx
->
priv_data
,
data
,
frame
);
gsm_encode
(
state
,
samples
,
avpkt
->
data
);
gsm_encode
(
avctx
->
priv_data
,((
short
*
)
data
)
+
GSM_FRAME_SIZE
,
frame
+
32
);
gsm_encode
(
state
,
samples
+
GSM_FRAME_SIZE
,
avpkt
->
data
+
32
);
}
}
return
avctx
->
block_align
;
*
got_packet_ptr
=
1
;
return
0
;
}
}
...
@@ -107,7 +121,7 @@ AVCodec ff_libgsm_encoder = {
...
@@ -107,7 +121,7 @@ AVCodec ff_libgsm_encoder = {
.
type
=
AVMEDIA_TYPE_AUDIO
,
.
type
=
AVMEDIA_TYPE_AUDIO
,
.
id
=
CODEC_ID_GSM
,
.
id
=
CODEC_ID_GSM
,
.
init
=
libgsm_encode_init
,
.
init
=
libgsm_encode_init
,
.
encode
=
libgsm_encode_frame
,
.
encode
2
=
libgsm_encode_frame
,
.
close
=
libgsm_encode_close
,
.
close
=
libgsm_encode_close
,
.
sample_fmts
=
(
const
enum
AVSampleFormat
[]){
AV_SAMPLE_FMT_S16
,
AV_SAMPLE_FMT_NONE
},
.
sample_fmts
=
(
const
enum
AVSampleFormat
[]){
AV_SAMPLE_FMT_S16
,
AV_SAMPLE_FMT_NONE
},
.
long_name
=
NULL_IF_CONFIG_SMALL
(
"libgsm GSM"
),
.
long_name
=
NULL_IF_CONFIG_SMALL
(
"libgsm GSM"
),
...
@@ -118,7 +132,7 @@ AVCodec ff_libgsm_ms_encoder = {
...
@@ -118,7 +132,7 @@ AVCodec ff_libgsm_ms_encoder = {
.
type
=
AVMEDIA_TYPE_AUDIO
,
.
type
=
AVMEDIA_TYPE_AUDIO
,
.
id
=
CODEC_ID_GSM_MS
,
.
id
=
CODEC_ID_GSM_MS
,
.
init
=
libgsm_encode_init
,
.
init
=
libgsm_encode_init
,
.
encode
=
libgsm_encode_frame
,
.
encode
2
=
libgsm_encode_frame
,
.
close
=
libgsm_encode_close
,
.
close
=
libgsm_encode_close
,
.
sample_fmts
=
(
const
enum
AVSampleFormat
[]){
AV_SAMPLE_FMT_S16
,
AV_SAMPLE_FMT_NONE
},
.
sample_fmts
=
(
const
enum
AVSampleFormat
[]){
AV_SAMPLE_FMT_S16
,
AV_SAMPLE_FMT_NONE
},
.
long_name
=
NULL_IF_CONFIG_SMALL
(
"libgsm GSM Microsoft variant"
),
.
long_name
=
NULL_IF_CONFIG_SMALL
(
"libgsm GSM Microsoft variant"
),
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment