Coverage Report

Created: 2025-12-31 07:57

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/ffmpeg/libavcodec/bsf/ahx_to_mp2.c
Line
Count
Source
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
1.68k
{
33
1.68k
    ctx->par_out->codec_id = AV_CODEC_ID_MP2;
34
35
1.68k
    return 0;
36
1.68k
}
37
38
static int filter(AVBSFContext *ctx, AVPacket *pkt)
39
2.20M
{
40
2.20M
    int ret;
41
42
2.20M
    ret = ff_bsf_get_packet_ref(ctx, pkt);
43
2.20M
    if (ret < 0)
44
1.10M
        return ret;
45
46
1.09M
    if (pkt->size < 1044) {
47
1.09M
        int original_size = pkt->size;
48
1.09M
        ret = av_grow_packet(pkt, 1044-pkt->size);
49
1.09M
        if (ret < 0) {
50
0
            av_packet_unref(pkt);
51
0
            return ret;
52
0
        }
53
1.09M
        memset(pkt->data + original_size, 0, 1044 - original_size);
54
1.09M
    }
55
56
1.09M
    return 0;
57
1.09M
}
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
};