| 1958 | } |
| 1959 | |
| 1960 | static int setup_extradata( hb_work_private_t * pv, AVCodecContext * context ) |
| 1961 | { |
| 1962 | const AVBitStreamFilter * bsf; |
| 1963 | AVBSFContext * ctx = NULL; |
| 1964 | int ii, ret; |
| 1965 | AVPacket * avp = pv->pkt; |
| 1966 | const enum AVCodecID * ids; |
| 1967 | |
| 1968 | if (context->extradata != NULL) |
| 1969 | { |
| 1970 | return 0; |
| 1971 | } |
| 1972 | bsf = av_bsf_get_by_name("extract_extradata"); |
| 1973 | if (bsf == NULL) |
| 1974 | { |
| 1975 | hb_error("setup_extradata: bitstream filter lookup failure"); |
| 1976 | return 0; |
| 1977 | } |
| 1978 | if (bsf->codec_ids == NULL) |
| 1979 | { |
| 1980 | hb_error("setup_extradata: extract_extradata missing codec_ids"); |
| 1981 | return 0; |
| 1982 | } |
| 1983 | for (ids = bsf->codec_ids; *ids != AV_CODEC_ID_NONE; ids++) |
| 1984 | { |
| 1985 | if (*ids == context->codec_id) |
| 1986 | { |
| 1987 | break; |
| 1988 | } |
| 1989 | } |
| 1990 | if (*ids == AV_CODEC_ID_NONE) |
| 1991 | { |
| 1992 | // Codec not supported by extract_extradata BSF |
| 1993 | return 0; |
| 1994 | } |
| 1995 | ret = av_bsf_alloc(bsf, &ctx); |
| 1996 | if (ret < 0) |
| 1997 | { |
| 1998 | hb_error("setup_extradata: bitstream filter alloc failure"); |
| 1999 | return 0; |
| 2000 | } |
| 2001 | avcodec_parameters_from_context(ctx->par_in, context); |
| 2002 | ret = av_bsf_init(ctx); |
| 2003 | if (ret < 0) |
| 2004 | { |
| 2005 | hb_error("setup_extradata: bitstream filter init failure"); |
| 2006 | av_bsf_free(&ctx); |
| 2007 | return 0; |
| 2008 | } |
| 2009 | |
| 2010 | avp->data = pv->packet_info.data; |
| 2011 | avp->size = pv->packet_info.size; |
| 2012 | avp->pts = pv->sequence; |
| 2013 | avp->dts = pv->sequence; |
| 2014 | ret = av_bsf_send_packet(ctx, avp); |
| 2015 | if (ret < 0) |
| 2016 | { |
| 2017 | hb_error("setup_extradata: av_bsf_send_packet failure"); |
no test coverage detected