  
    struct buffer_data bd = {
      .data = (uint8_t *)content.data(),
      .offset = 0,
      .size = content.size(),
    };
    const int avio_ctx_buffer_size = 64 * 1024;
    unsigned char *avio_ctx_buffer = (unsigned char *)av_malloc(avio_ctx_buffer_size);
    avio_ctx_ = avio_alloc_context(avio_ctx_buffer, avio_ctx_buffer_size, 0, &bd, readPacket, nullptr, nullptr);
    input_ctx->pb = avio_ctx_;
 
</s> remove     .data = (uint8_t *)content.data(),
 </s> add     .data = (const uint8_t*)data, </s> remove   int ret = avformat_open_input(&input_ctx, url.c_str(), NULL, NULL);
 </s> add   int ret = avformat_open_input(&input_ctx, nullptr, nullptr, nullptr); </s> remove     printf("Error loading video - %s - %s\n", err_str, url.c_str());
 </s> add     printf("Error loading video - %s\n", err_str); </s> remove   s->frame = new FrameReader(true);
 </s> add   s->frame = new FrameReader();
    .size = size,
  
    struct buffer_data bd = {
      .data = (uint8_t *)content.data(),
      .offset = 0,
    .size = size,
    };
    const int avio_ctx_buffer_size = 64 * 1024;
    unsigned char *avio_ctx_buffer = (unsigned char *)av_malloc(avio_ctx_buffer_size);
    avio_ctx_ = avio_alloc_context(avio_ctx_buffer, avio_ctx_buffer_size, 0, &bd, readPacket, nullptr, nullptr);
    input_ctx->pb = avio_ctx_;
keep keep keep keep replace keep keep keep keep keep
 logreader: support reading from corrupt log (#23050)

* catch exception outside loop

* print decompress error

* add test case for corrupt log

* fix decompressbz2 stuck if log is corrupt

* recovered from corrupt data

* add output

* ass space

* std::endl

* override load(), load from buffer

* override FrameReader::load to load from the buffer

* replace NULL with nullptr

* fix test case for corrupt log

* Trigger Build

* check bzerror too

Co-authored-by: Willem Melching <willem.melching@gmail.com> 
selfdrive/ui/replay/framereader.cc