| Line | Branch | Exec | 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 | { | ||
| 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 | }; | ||
| 65 |