Revision 1e002b60

View differences:

libavcodec/svq3.c
703 703
    s->gb.size_in_bits = h->next_slice_index - 8*(length - 1);
704 704
    skip_bits(&s->gb, 8);
705 705

  
706
    if (h->svq3_watermark_key) {
707
        uint32_t header = AV_RL32(&s->gb.buffer[(get_bits_count(&s->gb)>>3)+1]);
708
        AV_WL32(&s->gb.buffer[(get_bits_count(&s->gb)>>3)+1], header ^ h->svq3_watermark_key);
709
    }
706 710
    if (length > 0) {
707 711
      memcpy ((uint8_t *) &s->gb.buffer[get_bits_count(&s->gb) >> 3],
708 712
             &s->gb.buffer[s->gb.size_in_bits >> 3], (length - 1));
......
828 832

  
829 833
      h->unknown_svq3_flag = get_bits1 (&gb);
830 834
      avctx->has_b_frames = !s->low_delay;
835
      if (h->unknown_svq3_flag) {
836
#ifdef CONFIG_ZLIB
837
          unsigned watermark_width  = svq3_get_ue_golomb(&gb);
838
          unsigned watermark_height = svq3_get_ue_golomb(&gb);
839
          int u1 = svq3_get_ue_golomb(&gb);
840
          int u2 = get_bits(&gb, 8);
841
          int u3 = get_bits(&gb, 2);
842
          int u4 = svq3_get_ue_golomb(&gb);
843
          unsigned buf_len = watermark_width*watermark_height*4;
844
          int offset = (get_bits_count(&gb)+7)>>3;
845
          uint8_t *buf;
846

  
847
          if ((uint64_t)watermark_width*4 > UINT_MAX/watermark_height)
848
              return -1;
849

  
850
          buf = av_malloc(buf_len);
851
          av_log(avctx, AV_LOG_DEBUG, "watermark size: %dx%d\n", watermark_width, watermark_height);
852
          av_log(avctx, AV_LOG_DEBUG, "u1: %x u2: %x u3: %x compressed data size: %d offset: %d\n", u1, u2, u3, u4, offset);
853
          if (uncompress(buf, (uLong*)&buf_len, extradata + 8 + offset, size - offset) != Z_OK) {
854
              av_log(avctx, AV_LOG_ERROR, "could not uncompress watermark logo\n");
855
              av_free(buf);
856
              return -1;
857
          }
858
          h->svq3_watermark_key = ff_svq1_packet_checksum(buf, buf_len, 0);
859
          h->svq3_watermark_key = h->svq3_watermark_key << 16 | h->svq3_watermark_key;
860
          av_log(avctx, AV_LOG_DEBUG, "watermark key %#x\n", h->svq3_watermark_key);
861
          av_free(buf);
862
#else
863
          av_log(avctx, AV_LOG_ERROR, "this svq3 file contains watermark which need zlib support compiled in\n");
864
          return -1;
865
#endif
866
      }
831 867
    }
832 868
  }
833 869

  

Also available in: Unified diff