LCOV - code coverage report
Current view: top level - libavcodec - movsub_bsf.c (source / functions) Hit Total Coverage
Test: coverage.info Lines: 0 42 0.0 %
Date: 2017-12-16 13:57:32 Functions: 0 2 0.0 %

          Line data    Source code
       1             : /*
       2             :  * Copyright (c) 2008 Reimar Döffinger
       3             :  *
       4             :  * This file is part of FFmpeg.
       5             :  *
       6             :  * FFmpeg is free software; you can redistribute it and/or
       7             :  * modify it under the terms of the GNU Lesser General Public
       8             :  * License as published by the Free Software Foundation; either
       9             :  * version 2.1 of the License, or (at your option) any later version.
      10             :  *
      11             :  * FFmpeg is distributed in the hope that it will be useful,
      12             :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      13             :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
      14             :  * Lesser General Public License for more details.
      15             :  *
      16             :  * You should have received a copy of the GNU Lesser General Public
      17             :  * License along with FFmpeg; if not, write to the Free Software
      18             :  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
      19             :  */
      20             : 
      21             : #include "libavutil/common.h"
      22             : #include "libavutil/intreadwrite.h"
      23             : #include "avcodec.h"
      24             : #include "bsf.h"
      25             : 
      26           0 : static int text2movsub(AVBSFContext *ctx, AVPacket *out)
      27             : {
      28             :     AVPacket *in;
      29           0 :     int ret = 0;
      30             : 
      31           0 :     ret = ff_bsf_get_packet(ctx, &in);
      32           0 :     if (ret < 0)
      33           0 :         return ret;
      34             : 
      35           0 :     if (in->size > 0xffff) {
      36           0 :         ret = AVERROR_INVALIDDATA;
      37           0 :         goto fail;
      38             :     }
      39             : 
      40           0 :     ret = av_new_packet(out, in->size + 2);
      41           0 :     if (ret < 0) {
      42           0 :         ret = AVERROR(ENOMEM);
      43           0 :         goto fail;
      44             :     }
      45             : 
      46           0 :     ret = av_packet_copy_props(out, in);
      47           0 :     if (ret < 0)
      48           0 :         goto fail;
      49             : 
      50           0 :     AV_WB16(out->data, in->size);
      51           0 :     memcpy(out->data + 2, in->data, in->size);
      52             : 
      53           0 : fail:
      54           0 :     if (ret < 0)
      55           0 :         av_packet_unref(out);
      56           0 :     av_packet_free(&in);
      57           0 :     return ret;
      58             : }
      59             : 
      60             : const AVBitStreamFilter ff_text2movsub_bsf = {
      61             :     .name   = "text2movsub",
      62             :     .filter = text2movsub,
      63             : };
      64             : 
      65           0 : static int mov2textsub(AVBSFContext *ctx, AVPacket *out)
      66             : {
      67             :     AVPacket *in;
      68           0 :     int ret = 0;
      69             : 
      70           0 :     ret = ff_bsf_get_packet(ctx, &in);
      71           0 :     if (ret < 0)
      72           0 :         return ret;
      73             : 
      74           0 :     if (in->size < 2) {
      75           0 :        ret = AVERROR_INVALIDDATA;
      76           0 :        goto fail;
      77             :     }
      78             : 
      79           0 :     ret = av_new_packet(out, FFMIN(in->size - 2, AV_RB16(in->data)));
      80           0 :     if (ret < 0)
      81           0 :         goto fail;
      82             : 
      83           0 :     ret = av_packet_copy_props(out, in);
      84           0 :     if (ret < 0)
      85           0 :         goto fail;
      86             : 
      87           0 :     memcpy(out->data, in->data + 2, out->size);
      88             : 
      89           0 : fail:
      90           0 :     if (ret < 0)
      91           0 :         av_packet_unref(out);
      92           0 :     av_packet_free(&in);
      93           0 :     return ret;
      94             : }
      95             : 
      96             : const AVBitStreamFilter ff_mov2textsub_bsf = {
      97             :     .name   = "mov2textsub",
      98             :     .filter = mov2textsub,
      99             : };

Generated by: LCOV version 1.13