FFmpeg
libavcodec
bsf
ahx_to_mp2.c
Go to the documentation of this file.
1
/*
2
* AHX to MP2 bitstream filter
3
* Copyright (c) 2024 Paul B Mahol
4
*
5
* This file is part of FFmpeg.
6
*
7
* FFmpeg is free software; you can redistribute it and/or
8
* modify it under the terms of the GNU Lesser General Public
9
* License as published by the Free Software Foundation; either
10
* version 2.1 of the License, or (at your option) any later version.
11
*
12
* FFmpeg is distributed in the hope that it will be useful,
13
* but WITHOUT ANY WARRANTY; without even the implied warranty of
14
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15
* Lesser General Public License for more details.
16
*
17
* You should have received a copy of the GNU Lesser General Public
18
* License along with FFmpeg; if not, write to the Free Software
19
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20
*/
21
22
/**
23
* @file
24
* AHX to MP2 bitstream filter.
25
*/
26
27
#include "
libavutil/intreadwrite.h
"
28
#include "
bsf.h
"
29
#include "
bsf_internal.h
"
30
31
static
av_cold
int
init
(
AVBSFContext
*
ctx
)
32
{
33
ctx
->par_out->codec_id =
AV_CODEC_ID_MP2
;
34
35
return
0;
36
}
37
38
static
int
filter
(
AVBSFContext
*
ctx
,
AVPacket
*
pkt
)
39
{
40
int
ret
;
41
42
ret
=
ff_bsf_get_packet_ref
(
ctx
,
pkt
);
43
if
(
ret
< 0)
44
return
ret
;
45
46
if
(
pkt
->
size
< 1044) {
47
int
original_size =
pkt
->
size
;
48
ret
=
av_grow_packet
(
pkt
, 1044-
pkt
->
size
);
49
if
(
ret
< 0) {
50
av_packet_unref
(
pkt
);
51
return
ret
;
52
}
53
memset(
pkt
->
data
+ original_size, 0, 1044 - original_size);
54
}
55
56
return
0;
57
}
58
59
const
FFBitStreamFilter
ff_ahx_to_mp2_bsf
= {
60
.
p
.
name
=
"ahx_to_mp2"
,
61
.p.codec_ids = (
const
enum
AVCodecID
[]){
AV_CODEC_ID_AHX
,
AV_CODEC_ID_NONE
},
62
.init =
init
,
63
.filter =
filter
,
64
};
av_packet_unref
void av_packet_unref(AVPacket *pkt)
Wipe the packet.
Definition:
packet.c:433
bsf_internal.h
AVBitStreamFilter::name
const char * name
Definition:
bsf.h:112
av_grow_packet
int av_grow_packet(AVPacket *pkt, int grow_by)
Increase packet size, correctly zeroing padding.
Definition:
packet.c:122
AVPacket::data
uint8_t * data
Definition:
packet.h:558
ff_ahx_to_mp2_bsf
const FFBitStreamFilter ff_ahx_to_mp2_bsf
Definition:
ahx_to_mp2.c:59
AVBSFContext
The bitstream filter state.
Definition:
bsf.h:68
bsf.h
pkt
AVPacket * pkt
Definition:
movenc.c:60
av_cold
#define av_cold
Definition:
attributes.h:100
intreadwrite.h
AV_CODEC_ID_MP2
@ AV_CODEC_ID_MP2
Definition:
codec_id.h:459
ctx
AVFormatContext * ctx
Definition:
movenc.c:49
FFBitStreamFilter
Definition:
bsf_internal.h:27
AVCodecID
AVCodecID
Identify the syntax and semantics of the bitstream.
Definition:
codec_id.h:49
FFBitStreamFilter::p
AVBitStreamFilter p
The public AVBitStreamFilter.
Definition:
bsf_internal.h:31
AVPacket::size
int size
Definition:
packet.h:559
init
static av_cold int init(AVBSFContext *ctx)
Definition:
ahx_to_mp2.c:31
AV_CODEC_ID_NONE
@ AV_CODEC_ID_NONE
Definition:
codec_id.h:50
AV_CODEC_ID_AHX
@ AV_CODEC_ID_AHX
Definition:
codec_id.h:567
ret
ret
Definition:
filter_design.txt:187
filter
static int filter(AVBSFContext *ctx, AVPacket *pkt)
Definition:
ahx_to_mp2.c:38
AVPacket
This structure stores compressed data.
Definition:
packet.h:535
ff_bsf_get_packet_ref
int ff_bsf_get_packet_ref(AVBSFContext *ctx, AVPacket *pkt)
Called by bitstream filters to get packet for filtering.
Definition:
bsf.c:256
Generated on Mon Oct 6 2025 19:22:02 for FFmpeg by
1.8.17