static int dvbsub_decode(AVCodecContext *avctx,

                         void *data, int *data_size,

                         AVPacket *avpkt)

{

    const uint8_t *buf = avpkt->data;

    int buf_size = avpkt->size;

    DVBSubContext *ctx = avctx->priv_data;

    AVSubtitle *sub = data;

    const uint8_t *p, *p_end;

    int segment_type;

    int page_id;

    int segment_length;



#ifdef DEBUG_PACKET_CONTENTS

    int i;



    av_log(avctx, AV_LOG_INFO, "DVB sub packet:\n");



    for (i=0; i < buf_size; i++) {

        av_log(avctx, AV_LOG_INFO, "%02x ", buf[i]);

        if (i % 16 == 15)

            av_log(avctx, AV_LOG_INFO, "\n");

    }



    if (i % 16)

        av_log(avctx, AV_LOG_INFO, "\n");



#endif



    if (buf_size <= 2 || *buf != 0x0f)

        return -1;



    p = buf;

    p_end = buf + buf_size;



    while (p < p_end && *p == 0x0f) {

        p += 1;

        segment_type = *p++;

        page_id = AV_RB16(p);

        p += 2;

        segment_length = AV_RB16(p);

        p += 2;



        if (page_id == ctx->composition_id || page_id == ctx->ancillary_id ||

            ctx->composition_id == -1 || ctx->ancillary_id == -1) {

            switch (segment_type) {

            case DVBSUB_PAGE_SEGMENT:

                dvbsub_parse_page_segment(avctx, p, segment_length);

                break;

            case DVBSUB_REGION_SEGMENT:

                dvbsub_parse_region_segment(avctx, p, segment_length);

                break;

            case DVBSUB_CLUT_SEGMENT:

                dvbsub_parse_clut_segment(avctx, p, segment_length);

                break;

            case DVBSUB_OBJECT_SEGMENT:

                dvbsub_parse_object_segment(avctx, p, segment_length);

                break;

            case DVBSUB_DISPLAYDEFINITION_SEGMENT:

                dvbsub_parse_display_definition_segment(avctx, p, segment_length);

            case DVBSUB_DISPLAY_SEGMENT:

                *data_size = dvbsub_display_end_segment(avctx, p, segment_length, sub);

                break;

            default:

                av_dlog(avctx, "Subtitling segment type 0x%x, page id %d, length %d\n",

                        segment_type, page_id, segment_length);

                break;

            }

        }



        p += segment_length;

    }



    return p - buf;

}

static int dvbsub_decode(AVCodecContext *avctx,

                         void *data, int *data_size,

                         AVPacket *avpkt)

{

    const uint8_t *buf = avpkt->data;

    int buf_size = avpkt->size;

    DVBSubContext *ctx = avctx->priv_data;

    AVSubtitle *sub = data;

    const uint8_t *p, *p_end;

    int segment_type;

    int page_id;

    int segment_length;



#ifdef DEBUG_PACKET_CONTENTS

    int i;



    av_log(avctx, AV_LOG_INFO, "DVB sub packet:\n");



    for (i=0; i < buf_size; i++) {

        av_log(avctx, AV_LOG_INFO, "%02x ", buf[i]);

        if (i % 16 == 15)

            av_log(avctx, AV_LOG_INFO, "\n");

    }



    if (i % 16)

        av_log(avctx, AV_LOG_INFO, "\n");



#endif



    if (buf_size <= 2 || *buf != 0x0f)

        return -1;



    p = buf;

    p_end = buf + buf_size;



    while (p < p_end && *p == 0x0f) {

        p += 1;

        segment_type = *p++;

        page_id = AV_RB16(p);

        p += 2;

        segment_length = AV_RB16(p);

        p += 2;



        if (page_id == ctx->composition_id || page_id == ctx->ancillary_id ||

            ctx->composition_id == -1 || ctx->ancillary_id == -1) {

            switch (segment_type) {

            case DVBSUB_PAGE_SEGMENT:

                dvbsub_parse_page_segment(avctx, p, segment_length);

                break;

            case DVBSUB_REGION_SEGMENT:

                dvbsub_parse_region_segment(avctx, p, segment_length);

                break;

            case DVBSUB_CLUT_SEGMENT:

                dvbsub_parse_clut_segment(avctx, p, segment_length);

                break;

            case DVBSUB_OBJECT_SEGMENT:

                dvbsub_parse_object_segment(avctx, p, segment_length);

                break;

            case DVBSUB_DISPLAYDEFINITION_SEGMENT:

                dvbsub_parse_display_definition_segment(avctx, p, segment_length);

            case DVBSUB_DISPLAY_SEGMENT:

                *data_size = dvbsub_display_end_segment(avctx, p, segment_length, sub);

                break;

            default:

                av_dlog(avctx, "Subtitling segment type 0x%x, page id %d, length %d\n",

                        segment_type, page_id, segment_length);

                break;

            }

        }



        p += segment_length;

    }



    return p - buf;

}

    if (buf_size <= 2 || *buf != 0x0f)     while (p < p_end && *p == 0x0f) {
static int FUNC_0(AVCodecContext *VAR_0,

                         void *VAR_1, int *VAR_2,

                         AVPacket *VAR_3)

{

    const uint8_t *VAR_4 = VAR_3->VAR_1;

    int VAR_5 = VAR_3->size;

    DVBSubContext *ctx = VAR_0->priv_data;

    AVSubtitle *sub = VAR_1;

    const uint8_t *VAR_6, *p_end;

    int VAR_7;

    int VAR_8;

    int VAR_9;



#ifdef DEBUG_PACKET_CONTENTS

    int i;



    av_log(VAR_0, AV_LOG_INFO, "DVB sub packet:\n");



    for (i=0; i < VAR_5; i++) {

        av_log(VAR_0, AV_LOG_INFO, "%02x ", VAR_4[i]);

        if (i % 16 == 15)

            av_log(VAR_0, AV_LOG_INFO, "\n");

    }



    if (i % 16)

        av_log(VAR_0, AV_LOG_INFO, "\n");



#endif



    if (VAR_5 <= 2 || *VAR_4 != 0x0f)

        return -1;



    VAR_6 = VAR_4;

    p_end = VAR_4 + VAR_5;



    while (VAR_6 < p_end && *VAR_6 == 0x0f) {

        VAR_6 += 1;

        VAR_7 = *VAR_6++;

        VAR_8 = AV_RB16(VAR_6);

        VAR_6 += 2;

        VAR_9 = AV_RB16(VAR_6);

        VAR_6 += 2;



        if (VAR_8 == ctx->composition_id || VAR_8 == ctx->ancillary_id ||

            ctx->composition_id == -1 || ctx->ancillary_id == -1) {

            switch (VAR_7) {

            case DVBSUB_PAGE_SEGMENT:

                dvbsub_parse_page_segment(VAR_0, VAR_6, VAR_9);

                break;

            case DVBSUB_REGION_SEGMENT:

                dvbsub_parse_region_segment(VAR_0, VAR_6, VAR_9);

                break;

            case DVBSUB_CLUT_SEGMENT:

                dvbsub_parse_clut_segment(VAR_0, VAR_6, VAR_9);

                break;

            case DVBSUB_OBJECT_SEGMENT:

                dvbsub_parse_object_segment(VAR_0, VAR_6, VAR_9);

                break;

            case DVBSUB_DISPLAYDEFINITION_SEGMENT:

                dvbsub_parse_display_definition_segment(VAR_0, VAR_6, VAR_9);

            case DVBSUB_DISPLAY_SEGMENT:

                *VAR_2 = dvbsub_display_end_segment(VAR_0, VAR_6, VAR_9, sub);

                break;

            default:

                av_dlog(VAR_0, "Subtitling segment type 0x%x, page id %d, length %d\n",

                        VAR_7, VAR_8, VAR_9);

                break;

            }

        }



        VAR_6 += VAR_9;

    }



    return VAR_6 - VAR_4;

}

static int FUNC_0(AVCodecContext *VAR_0,
void *VAR_1, int *VAR_2,
AVPacket *VAR_3)
{ const uint8_t *VAR_4 = VAR_3->VAR_1; int VAR_5 = VAR_3->size; DVBSubContext *ctx = VAR_0->priv_data; AVSubtitle *sub = VAR_1; const uint8_t *VAR_6, *p_end; int VAR_7; int VAR_8; int VAR_9; #ifdef DEBUG_PACKET_CONTENTS
int i; av_log(VAR_0, AV_LOG_INFO, "DVB sub packet:\n"); for (i=0; i < VAR_5; i++) { av_log(VAR_0, AV_LOG_INFO, "%02x ", VAR_4[i]); if (i % 16 == 15)
av_log(VAR_0, AV_LOG_INFO, "\n"); } if (i % 16)
av_log(VAR_0, AV_LOG_INFO, "\n"); #endif
if (VAR_5 <= 2 || *VAR_4 != 0x0f)
return -1; VAR_6 = VAR_4; p_end = VAR_4 + VAR_5; while (VAR_6 < p_end && *VAR_6 == 0x0f) { VAR_6 += 1; VAR_7 = *VAR_6++; VAR_8 = AV_RB16(VAR_6); VAR_6 += 2; VAR_9 = AV_RB16(VAR_6); VAR_6 += 2; if (VAR_8 == ctx->composition_id || VAR_8 == ctx->ancillary_id ||
ctx->composition_id == -1 || ctx->ancillary_id == -1) { switch (VAR_7) { case DVBSUB_PAGE_SEGMENT:
dvbsub_parse_page_segment(VAR_0, VAR_6, VAR_9); break; case DVBSUB_REGION_SEGMENT:
dvbsub_parse_region_segment(VAR_0, VAR_6, VAR_9); break; case DVBSUB_CLUT_SEGMENT:
dvbsub_parse_clut_segment(VAR_0, VAR_6, VAR_9); break; case DVBSUB_OBJECT_SEGMENT:
dvbsub_parse_object_segment(VAR_0, VAR_6, VAR_9); break; case DVBSUB_DISPLAYDEFINITION_SEGMENT:
dvbsub_parse_display_definition_segment(VAR_0, VAR_6, VAR_9); case DVBSUB_DISPLAY_SEGMENT:
*VAR_2 = dvbsub_display_end_segment(VAR_0, VAR_6, VAR_9, sub); break; default:
av_dlog(VAR_0, "Subtitling segment type 0x%x, page id %d, length %d\n",
VAR_7, VAR_8, VAR_9); break; } } VAR_6 += VAR_9; } return VAR_6 - VAR_4; }